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…
With knowledge of extending Subscriber and using source.lift to connect a source to a subscriber, you can now create your own operators by writing functions that return a source.lift call. This lesson creates a simple "multiply" operator in RxJS…
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();…
条目二十四<当效率至关重要时,请在map::operator[]与map::insert之间谨慎做出选择> 当效率至关重要时,应该在map::operator[]和map::insert之间仔细做出选择.如果要更新一个已有的映射表元素,则应该优先选择operator[]:但如果要添加一个新的元素,那么最好还是选择insert. 下面来分析为什么是这样子的. 首先先说明,下面两个式子是等价的: map<int, int> ss; ss[1]=2 //式子1 ss.insert(pai…
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…
A small coding test that I encountered today. Question Using only primitive types, implement a fixed-size hash map that associates string keys with arbitrary data object references (you don't need to copy the object). Your data structure should be op…
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…
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,…
Like an array, Observable has a map method that allows us to transform a sequence into a new Observable. var Observable = Rx.Observable; //Create click events by Observable var clicks = Observable.fromEvent(button, 'click'); var points = clicks.map(f…
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…