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
官網(wǎng)鏈接:reactivex
buffer&Window
同:將數(shù)據(jù)按序緩存从绘,緩存大小由用戶存入占卧,每收集到count個(gè)數(shù)據(jù)發(fā)送一次(接收到onComplete()并未收集到count個(gè)數(shù)據(jù)時(shí)也會(huì)發(fā)送)贵涵;也可以按時(shí)間緩存,沒隔一段時(shí)間發(fā)送一次血柳。
異:buffer緩存后發(fā)射的是list數(shù)據(jù)集官册,而window緩存后會(huì)包裝成一個(gè)Observable發(fā)射
注意:緩存中遇到onError()時(shí),已緩存但未發(fā)射的數(shù)據(jù)將被拋棄,之后的數(shù)據(jù)也不會(huì)發(fā)送
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
異:發(fā)射的數(shù)據(jù)不同:function和Observable
GroupBy
將一組數(shù)據(jù)分組包裝成Observable發(fā)射出去难捌。每個(gè)數(shù)據(jù)會(huì)返回一個(gè)key,這些包含相同key的數(shù)據(jù)將被收集在一起
scan
累加器的效果