switchMap is mergeMap that checks for an "inner" subscription. If the "inner" subscription exists, switchMap unsubscribes from that "inner" subscription which effectively "cancels" any pending pushes. import { fromE…
Unlike mergeMap and switchMap, concatMap focuses on when "inner" subscriptions "complete" by using a "buffer". Each time concatMap receives a value, it adds each value to a "buffer", waits for previous "inner&q…
Understanding sources and subscribers makes it much easier to understand what's going on with mergeMap under the hood. Where a typical operator invokes destination.next directly, mergeMap wraps destination.next inside of a new source/subscriber combo…
While it's great to use the RxJS built-in operators, it's also important to realize you now have the knowledge to write them by yourself if needed. The mapoperator turns out to be a simple MapSubscriber which takes a function and applies it to the va…
exhaustMap: It drop the outter observable, just return the inner observable, and it waits until previous observable complete before emit next observable. Good for canceling extra network outter request, for example click (outter) request trigger netw…
Eventually you will feel the need for pausing the observation of an Observable and resuming it later. In this lesson we will learn about use cases where pausing is possible, and what to do when pausing is impossible. const resume$ = new Rx.Subject();…
Like switchMap and mergeMap, concatMap is a shortcut for map() followed by a concatAll(). In this lesson we will explore this RxJS operator and its properties. const clickObservable = Rx.Observable .fromEvent(document, 'click'); function performReque…
Like RxJS switchMap() is a shortcut for map() and switch(), we will see in this lesson how mergeMap() is a shortcut for map() and mergeAll(), and learn its arguments for customised behavior. const clickObservable = Rx.Observable .fromEvent(document,…
Instead of writing complex operators, it's usually best to write simple, single-purpose operators then chain them together when necessary. The pipefunction takes functions as arguments, invokes each function with the value, then passes the returned r…
The use of RxJS Subjects is common, but not without problems. In this lesson we will see how they can be usually safely replaced with plain Observables. Check the follow code: const click$ = new Rx.Subject(); document.addEventListener('click', functi…