Wednesday, December 5, 2018

There are quite a few Observables keywords that I have not used before.

Today a coworker had a pipe in which first an Observable which was doing polling forever was being merged with an Observable that would squawk if the polling took too long, then first() was called to bring back either the squawking or the successful result from the polling, and finally .switchMap was used to make the Observable of Observable of any just an Observable of any. .mergeMap is different from .merge in that .merge will merge Observables into Observables of Observables while .mergeMap tries to append to a different sequence of Observables. .from maps to an Observable and you may use .from to make an array of "foo", "bar", "baz", and "qux" an Observable that runs through the four things. Obviously, if you just put this to the UI templates with the async pipe you are just going to see the "qux" which might make you wonder why you should care. If you are looping through four actions for the Redux store, that is a bit different right? This is how one emits multiple things with a side event.

No comments:

Post a Comment