Rxjava Transtorming Observables

Operators that transform items that are emitted by an Observable.

Buffer — periodically gather items from an Observable into bundles and emit these bundles rather than emitting the items one at a time

FlatMap — transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable

GroupBy — divide an Observable into a set of Observables that each emit a different group of items from the original Observable, organized by key

Map — transform the items emitted by an Observable by applying a function to each item

Scan — apply a function to each item emitted by an Observable, sequentially, and emit each successive value

Window — periodically subdivide items from an Observable into Observable windows and emit these windows rather than emitting the items one at a time

官网链接:reactivex


buffer&Window

同:将数据按序缓存,缓存大小由用户存入,每收集到count个数据发送一次(接收到onComplete()并未收集到count个数据时也会发送);也可以按时间缓存,没隔一段时间发送一次。

异:buffer缓存后发射的是list数据集,而window缓存后会包装成一个Observable发射

注意:缓存中遇到onError()时,已缓存但未发射的数据将被抛弃,之后的数据也不会发送

buffer


window



Map&FlatMap

transform the items emitted by an Observable by applying a function to each item

transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable

异:发射的数据不同:function和Observable

map&flatMap



GroupBy

将一组数据分组包装成Observable发射出去。每个数据会返回一个key,这些包含相同key的数据将被收集在一起

groupBy



scan

累加器的效果

scan

你可能感兴趣的:(Rxjava Transtorming Observables)