Buffer
periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a time
The Buffer operator transforms an Observable that emits items into an Observable that emits buffered collections of those items. There are a number of variants in the various language-specific implementations of Buffer that differ in how they choose which items go in which buffers.
Note that if the source Observable issues an
onError
notification, Buffer will pass on this notification immediately without first emitting the buffer it is in the process of assembling, even if that buffer contains items that were emitted by the source Observable before it issued the error notification.
Code
-------------------------------------------------------
// buffer(int count)
Observable.fromIterable(list2).buffer(3).subscribe(System.out::println);
// buffer(int count, int skip)
Observable.fromIterable(list2).buffer(5, 3).subscribe(System.out::println);
// buffer(long timespan, TimeUnit unit)
Observable.fromIterable(list2).buffer(5000, TimeUnit.MILLISECONDS).subscribe(System.out::println);
------------------------------------------------------
For more depth : https://ninmesara.github.io/RxPY/api/operators/buffer.html
22
No comments:
Post a Comment