Introduction
Operators that transform items that are emitted by an Observable.
Map
Applies a function to each emitted item. It transforms each emitted item by applying a function to it.
Diagram:
Buffer
Periodically gather items from an Observable into bundles and emit the bundles rather than emitting items one at a time.
Diagram:
Debounce
Only emit an item from an Observable if a particular timespan has passed without it emitting another item.
Diagram:
ThrottleFirst
Filters out items emitted by the source Observable that are within a timespan.
Diagram:
FlatMap
Transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable. If you're familiar with LiveData, MediatorLiveData can do something very similar. I'll talk more about that in this blog on FlatMap().
Diagram:
ConcatMap
Transform the items emitted by an Observable into Observables. This is essentially the same thing as FlapMap(), but the order is preserved. But because ConcatMap() must wait for each observable to complete its work, technically it's not asynchronous.
Diagram:
SwitchMap
SwitchMap() will transform items emitted by an Observable into an Observable just like ConcatMap() and FlatMap(). The difference being that it will unsubscribe previous observers once a new Observer has subscribed. Essentially this solves a limitation that both ConcatMap() and FlatMap() have.
Thiếu nhiều toán tử quá, như timer...
ردحذفỞ bài viết sau mình sẽ cố gắng cập nhật thêm những toán tử nữa, cùng đón chờ nhé!
حذفإرسال تعليق
Cảm ơn bạn đã quan tâm và bày tỏ :D