constgetMoneyBack=(money:number):Observable<number>=>{returnnewObservable(subscriber=>{if(typeofmoney!=='number'){subscriber.error(newError('money is not a number'))}else{subscriber.next(money)subscriber.complete()}}constmoneySubscription:Subscription=getMoneyBack(1200).subscribe({next:money=>console.log(money),error:error=>console.log(error)})moneySubscription.unsubscribe()
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Callbacks vs Promises in JavaScript
For further actions, you may consider blocking this person and/or reporting abuse