본문

180107(수) - RxJava2 (buffer)

RxJava2 


buffer


periodically gather items emitted by an Observable into bundles and emit these bundles rather than emitting the items one at a time

Buffer

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 Publisher to honor it as well, although not enforced; violation may lead to MissingBackpressureException somewhere downstream.
Scheduler:
This version of buffer does not operate by default on a particular Scheduler.
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 to MissingBackpressureException somewhere downstream.
Scheduler:
This version of buffer does not operate by default on a particular Scheduler.
Parameters:
count - the maximum size of each buffer before it should be emitted
skip - how many items emitted by the source Publisher should be skipped before starting a new buffer. Note that when skip and count are equal, this is the same operation as buffer(int).
Returns:
a Flowable that emits buffers for every skip item from the source Publisher and containing at most count 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 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 to MissingBackpressureException somewhere downstream.
Scheduler:
This version of buffer does not operate by default on a particular Scheduler.
Type Parameters:
U - the collection subclass type to buffer into
Parameters:
count - the maximum size of each buffer before it should be emitted
skip - how many items emitted by the source Publisher should be skipped before starting a new buffer. Note that when skip and count are equal, this is the same operation as buffer(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 most count 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 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 to MissingBackpressureException somewhere downstream.
Scheduler:
This version of buffer does not operate by default on a particular Scheduler.
Type Parameters:
U - the collection subclass type to buffer into
Parameters:
count - the maximum number of items in each buffer before it should be emitted
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 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 the timeskip argument. It emits each buffer after a fixed timespan, specified by the timespanargument. 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 the computation Scheduler.
Parameters:
timespan - the period of time each buffer collects items before it is emitted
timeskip - the period of time after which a new buffer will be created
unit - the unit of time that applies to the timespan and timeskip 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 the timeskip argument, and on the specified scheduler. It emits each buffer after a fixed timespan, specified by the timespan 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 emitted
timeskip - the period of time after which a new buffer will be created
unit - the unit of time that applies to the timespan and timeskip arguments
scheduler - the Scheduler 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 the timeskip argument, and on the specified scheduler. It emits each buffer after a fixed timespan, specified by the timespan 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 emitted
timeskip - the period of time after which a new buffer will be created
unit - the unit of time that applies to the timespan and timeskip arguments
scheduler - the Scheduler to use when determining the end and start of a buffer
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 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 the timespan 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 the computation Scheduler.
Parameters:
timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
unit - the unit of time that applies to the timespan 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 the computation Scheduler.
Parameters:
timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
unit - the unit of time which applies to the timespan argument
count - 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

공유

댓글