본문
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 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
Publisher
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does 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
count
items 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
Publisher
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does 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 whenskip
andcount
are equal, this is the same operation asbuffer(int)
.- Returns:
- a Flowable that emits buffers for every
skip
item from the source Publisher and containing at mostcount
items - 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 everyskip
items, each containingcount
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
Publisher
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does 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 whenskip
andcount
are 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
skip
item from the source Publisher and containing at mostcount
items - 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 containingcount
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
Publisher
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does 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
count
items 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 thetimeskip
argument. It emits each buffer after a fixed timespan, specified by thetimespan
argument. 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_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- 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 thetimespan
andtimeskip
arguments- 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 thetimeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. 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_VALUE
upstream and does not obey downstream requests. - Scheduler:
- You specify which
Scheduler
this 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 thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to 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 thetimeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. 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_VALUE
upstream and does not obey downstream requests. - Scheduler:
- You specify which
Scheduler
this 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 thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to 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 thetimespan
argument. 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_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- 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 thetimespan
argument- 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_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- 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 thetimespan
argumentcount
- 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 |
댓글