How to get the “current” value of an Observer at subscribe-time

Rx offers both behaviors (as well as others). The different Rx Subjects available can let you explore the different ways observables can behave: the Rx.Subject is the most basic fire-and-forget variety — if you were not subscribed when the event happened, then you do not see it. Use new Rx.BehaviorSubject(undefined) instead of Subject and you … Read more

Why we should use RxJs of() function?

The reason why they’re using of() is because it’s very easy to use it instead of a real HTTP call. In a real application you would implement getHeroes() like this for example: getHeroes(): Observable<Hero[]> { return this.http.get(`/heroes`); } But since you just want to use a mocked response without creating any real backend you can … Read more

How to do the chain sequence in rxjs

The equivalent of then for observables would be flatMap. You can see some examples of use here : RxJS Promise Composition (passing data) Why we need to use flatMap? RxJS sequence equvalent to promise.then()? For your example, you could do something like : this._myService.doSomething() .flatMap(function(x){return functionReturningObservableOrPromise(x)}) .flatMap(…ad infinitum) .subscribe(…final processing) Pay attention to the types … Read more

throwError(error) is now deprecated, but there is no new Error(HttpErrorResponse)

Instead of this: catchError((error) => { this.authService.signOut(); return throwError(error); }), You could try this: catchError((error) => { this.authService.signOut(); return throwError(() => error); }), I wasn’t able to test it thoroughly, but a simple attempt seemed to work. This was my simple test (using RxJS v7.2): Service getProducts(): Observable<IProduct[]> { return this.http.get<IProduct[]>(this.productUrl) .pipe( tap(data => console.log(‘All: … Read more

How do I throw an error on a behaviour subject and continue the stream?

Short answer: It’s not possible. How to work with this: The basic concept of RxJS is that any error or complete-call will basically “kill” a stream. This concept forces you not “just to throw around errors here and there as you please” but to handle errors and the flow of data within your application properly. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)