假设我知道Observable<String> playerNames
第一个元素是标题。我如何将它分解成多个块(同时为每个组添加一个标题)?
playerNamesObservable
.window(100)
.to(chunk -> { return playerNamesObservable.concatWith(chunk) }
headerObservable
基本上在哪里playerNamesObservable.first()
问题是我想非常小心地发射物品(不想使用blockingGet
等)
谢谢
使用publish
:
recordsObservable.publish(shared -> {
Observable<String> first = shared
.take(1)
.replay()
.autoConnect(0);
return shared.skip(1)
.window(100)
.map(w -> w.startWith(first));
})
.flatMap(chunk -> /* consume each chunk */)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句