본문
180107(수) - RxJava2 (buffer)
Mobile/RxJava2 2018. 2. 7. 15:12
RxJava2
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.
The Window operator is similar to Buffer but collects items into separate Observables rather than into data structures before reemitting them.
buffer
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final Flowable<java.util.List<T>> buffer(int count)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher emits connected, non-overlapping buffers, each containing
count items. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- The operator honors backpressure from downstream and expects the source
Publisherto honor it as well, although not enforced; violation may lead toMissingBackpressureExceptionsomewhere downstream. - Scheduler:
- This version of
bufferdoes not operate by default on a particularScheduler.
- Parameters:
count- the maximum number of items in each buffer before it should be emitted- Returns:
- a Flowable that emits connected, non-overlapping buffers, each containing at most
countitems from the source Publisher - See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final Flowable<java.util.List<T>> buffer(int count, int skip)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher emits buffers every
skip items, each containing count items. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- The operator honors backpressure from downstream and expects the source
Publisherto honor it as well, although not enforced; violation may lead toMissingBackpressureExceptionsomewhere downstream. - Scheduler:
- This version of
bufferdoes not operate by default on a particularScheduler.
- Parameters:
count- the maximum size of each buffer before it should be emittedskip- how many items emitted by the source Publisher should be skipped before starting a new buffer. Note that whenskipandcountare equal, this is the same operation asbuffer(int).- Returns:
- a Flowable that emits buffers for every
skipitem from the source Publisher and containing at mostcountitems - See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final <U extends java.util.Collection<? super T>> Flowable<U> buffer(int count, int skip, java.util.concurrent.Callable<U> bufferSupplier)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher emits buffers everyskipitems, each containingcountitems. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- The operator honors backpressure from downstream and expects the source
Publisherto honor it as well, although not enforced; violation may lead toMissingBackpressureExceptionsomewhere downstream. - Scheduler:
- This version of
bufferdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the collection subclass type to buffer into- Parameters:
count- the maximum size of each buffer before it should be emittedskip- how many items emitted by the source Publisher should be skipped before starting a new buffer. Note that whenskipandcountare equal, this is the same operation asbuffer(int).bufferSupplier- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- a Flowable that emits buffers for every
skipitem from the source Publisher and containing at mostcountitems - See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final <U extends java.util.Collection<? super T>> Flowable<U> buffer(int count, java.util.concurrent.Callable<U> bufferSupplier)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher emits connected, non-overlapping buffers, each containingcountitems. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- The operator honors backpressure from downstream and expects the source
Publisherto honor it as well, although not enforced; violation may lead toMissingBackpressureExceptionsomewhere downstream. - Scheduler:
- This version of
bufferdoes not operate by default on a particularScheduler.
- Type Parameters:
U- the collection subclass type to buffer into- Parameters:
count- the maximum number of items in each buffer before it should be emittedbufferSupplier- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- a Flowable that emits connected, non-overlapping buffers, each containing at most
countitems from the source Publisher - See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=ERROR) @SchedulerSupport(value="io.reactivex:computation") public final Flowable<java.util.List<T>> buffer(long timespan, long timeskip, java.util.concurrent.TimeUnit unit)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher starts a new buffer periodically, as determined by thetimeskipargument. It emits each buffer after a fixed timespan, specified by thetimespanargument. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUEupstream and does not obey downstream requests. - Scheduler:
- This version of
bufferoperates by default on thecomputationScheduler.
- Parameters:
timespan- the period of time each buffer collects items before it is emittedtimeskip- the period of time after which a new buffer will be createdunit- the unit of time that applies to thetimespanandtimeskiparguments- Returns:
- a Flowable that emits new buffers of items emitted by the source Publisher periodically after a fixed timespan has elapsed
- See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=ERROR) @SchedulerSupport(value="custom") public final Flowable<java.util.List<T>> buffer(long timespan, long timeskip, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher starts a new buffer periodically, as determined by thetimeskipargument, and on the specifiedscheduler. It emits each buffer after a fixed timespan, specified by thetimespanargument. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUEupstream and does not obey downstream requests. - Scheduler:
- You specify which
Schedulerthis operator will use.
- Parameters:
timespan- the period of time each buffer collects items before it is emittedtimeskip- the period of time after which a new buffer will be createdunit- the unit of time that applies to thetimespanandtimeskipargumentsscheduler- theSchedulerto use when determining the end and start of a buffer- Returns:
- a Flowable that emits new buffers of items emitted by the source Publisher periodically after a fixed timespan has elapsed
- See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=ERROR) @SchedulerSupport(value="custom") public final <U extends java.util.Collection<? super T>> Flowable<U> buffer(long timespan, long timeskip, java.util.concurrent.TimeUnit unit, Scheduler scheduler, java.util.concurrent.Callable<U> bufferSupplier)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher starts a new buffer periodically, as determined by thetimeskipargument, and on the specifiedscheduler. It emits each buffer after a fixed timespan, specified by thetimespanargument. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUEupstream and does not obey downstream requests. - Scheduler:
- You specify which
Schedulerthis operator will use.
- Type Parameters:
U- the collection subclass type to buffer into- Parameters:
timespan- the period of time each buffer collects items before it is emittedtimeskip- the period of time after which a new buffer will be createdunit- the unit of time that applies to thetimespanandtimeskipargumentsscheduler- theSchedulerto use when determining the end and start of a bufferbufferSupplier- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- a Flowable that emits new buffers of items emitted by the source Publisher periodically after a fixed timespan has elapsed
- See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=ERROR) @SchedulerSupport(value="io.reactivex:computation") public final Flowable<java.util.List<T>> buffer(long timespan, java.util.concurrent.TimeUnit unit)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespanargument. When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUEupstream and does not obey downstream requests. - Scheduler:
- This version of
bufferoperates by default on thecomputationScheduler.
- Parameters:
timespan- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit- the unit of time that applies to thetimespanargument- Returns:
- a Flowable that emits connected, non-overlapping buffers of items emitted by the source Publisher within a fixed duration
- See Also:
- ReactiveX operators documentation: Buffer
buffer
@CheckReturnValue @BackpressureSupport(value=ERROR) @SchedulerSupport(value="io.reactivex:computation") public final Flowable<java.util.List<T>> buffer(long timespan, java.util.concurrent.TimeUnit unit, int count)
Returns a Flowable that emits buffers of items it collects from the source Publisher. The resulting Publisher emits connected, non-overlapping buffers, each of a fixed duration specified by the
timespan argument or a maximum size specified by the count argument (whichever is reached first). When the source Publisher completes or encounters an error, the resulting Publisher emits the current buffer and propagates the notification from the source Publisher.
- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUEupstream and does not obey downstream requests. - Scheduler:
- This version of
bufferoperates by default on thecomputationScheduler.
- Parameters:
timespan- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit- the unit of time which applies to thetimespanargumentcount- the maximum size of each buffer before it is emitted- Returns:
- a Flowable that emits connected, non-overlapping buffers of items emitted by the source Publisher, after a fixed duration or when the buffer reaches maximum capacity (whichever occurs first)
- See Also:
- ReactiveX operators documentation: Buffer
- .
- .
- .
- 이외에 엄청나게 많은 overloading 된 method들이 존재한다.
- 다 알아보기는 힘들고 buffer operator를 쓸 때 알맞게 찾아쓰면 될거같다.
'Mobile > RxJava2' 카테고리의 다른 글
| 180315(목) - RxJava2 (concatMap) (0) | 2018.03.15 |
|---|---|
| 180206(화) - RxJava2 (timer) (0) | 2018.02.06 |
| 180205(월) - RxJava2 (start) (0) | 2018.02.05 |
| 180104(목) - RxJava2 (repeat) (0) | 2018.01.04 |
| 180103(수) - RxJava2 (range) (0) | 2018.01.03 |
댓글