RxJava



rx.operators
Class OperationBuffer

java.lang.Object
  extended by rx.operators.ChunkedOperation
      extended by rx.operators.OperationBuffer

public final class OperationBuffer
extends ChunkedOperation


Nested Class Summary
protected static class OperationBuffer.Buffer<T>
          This class represents a single buffer: A sequence of recorded values.
 
Nested classes/interfaces inherited from class rx.operators.ChunkedOperation
ChunkedOperation.Chunk<T,C>, ChunkedOperation.ChunkCreator, ChunkedOperation.ChunkObserver<T,C>, ChunkedOperation.Chunks<T,C>, ChunkedOperation.NonOverlappingChunks<T,C>, ChunkedOperation.ObservableBasedMultiChunkCreator<T,C>, ChunkedOperation.ObservableBasedSingleChunkCreator<T,C>, ChunkedOperation.OverlappingChunks<T,C>, ChunkedOperation.SingleChunkCreator<T,C>, ChunkedOperation.SizeBasedChunks<T,C>, ChunkedOperation.SkippingChunkCreator<T,C>, ChunkedOperation.TimeAndSizeBasedChunks<T,C>, ChunkedOperation.TimeBasedChunkCreator<T,C>, ChunkedOperation.TimeBasedChunks<T,C>
 
Constructor Summary
OperationBuffer()
           
 
Method Summary
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, Func0<? extends Observable<? extends Closing>> bufferClosingSelector)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, int count)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, int count, int skip)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, long timespan, long timeshift, java.util.concurrent.TimeUnit unit)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, long timespan, long timeshift, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, long timespan, java.util.concurrent.TimeUnit unit)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, long timespan, java.util.concurrent.TimeUnit unit, int count)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, long timespan, java.util.concurrent.TimeUnit unit, int count, Scheduler scheduler)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, long timespan, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
          This method creates a Func1 object which represents the buffer operation.
static
<T> Observable.OnSubscribeFunc<java.util.List<T>>
buffer(Observable<T> source, Observable<? extends Opening> bufferOpenings, Func1<Opening,? extends Observable<? extends Closing>> bufferClosingSelector)
          This method creates a Func1 object which represents the buffer operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationBuffer

public OperationBuffer()
Method Detail

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       Func0<? extends Observable<? extends Closing>> bufferClosingSelector)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer until the Observable constructed using the Func0 argument, produces a Closing value. The buffer is then emitted, and a new buffer is created to replace it. A new Observable will be constructed using the provided Func0 object, which will determine when this new buffer is emitted. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation only produces non-overlapping chunks. At all times there is exactly one buffer actively storing values.

Parameters:
source - The Observable which produces values.
bufferClosingSelector - A Func0 object which produces Observables. These Observables determine when a buffer is emitted and replaced by simply producing an Closing object.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       Observable<? extends Opening> bufferOpenings,
                                                                       Func1<Opening,? extends Observable<? extends Closing>> bufferClosingSelector)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in the currently active chunks. Initially there are no chunks active.

Chunks can be created by pushing a Opening value to the "bufferOpenings" Observable. This creates a new buffer which will then start recording values which are produced by the "source" Observable. Additionally the "bufferClosingSelector" will be used to construct an Observable which can produce Closing values. When it does so it will close this (and only this) newly created buffer. When the source Observable completes or produces an error, all chunks are emitted, and the event is propagated to all subscribed Observers.

Note that when using this operation multiple overlapping chunks could be active at any one point.

Parameters:
source - The Observable which produces values.
bufferOpenings - An Observable which when it produces a Opening value will create a new buffer which instantly starts recording the "source" Observable.
bufferClosingSelector - A Func0 object which produces Observables. These Observables determine when a buffer is emitted and replaced by simply producing an Closing object.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       int count)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer until the buffer contains a specified number of elements. The buffer is then emitted, and a new buffer is created to replace it. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation only produces non-overlapping chunks. At all times there is exactly one buffer actively storing values.

Parameters:
source - The Observable which produces values.
count - The number of elements a buffer should have before being emitted and replaced.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       int count,
                                                                       int skip)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in all active chunks until the buffer contains a specified number of elements. The buffer is then emitted. Chunks are created after a certain amount of values have been received. When the source Observable completes or produces an error, the currently active chunks are emitted, and the event is propagated to all subscribed Observers.

Note that this operation can produce non-connected, connected non-overlapping, or overlapping chunks depending on the input parameters.

Parameters:
source - The Observable which produces values.
count - The number of elements a buffer should have before being emitted.
skip - The interval with which chunks have to be created. Note that when "skip" == "count" that this is the same as calling OperationBuffer.buffer(Observable, int). If "skip" < "count", this buffer operation will produce overlapping chunks and if "skip" > "count" non-overlapping chunks will be created and some values will not be pushed into a buffer at all!
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       long timespan,
                                                                       java.util.concurrent.TimeUnit unit)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation only produces non-overlapping chunks. At all times there is exactly one buffer actively storing values.

Parameters:
source - The Observable which produces values.
timespan - The amount of time all chunks must be actively collect values before being emitted.
unit - The TimeUnit defining the unit of time for the timespan.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       long timespan,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       Scheduler scheduler)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation only produces non-overlapping chunks. At all times there is exactly one buffer actively storing values.

Parameters:
source - The Observable which produces values.
timespan - The amount of time all chunks must be actively collect values before being emitted.
unit - The TimeUnit defining the unit of time for the timespan.
scheduler - The Scheduler to use for timing chunks.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       long timespan,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       int count)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. Additionally the buffer is automatically emitted once it reaches a specified number of elements. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation only produces non-overlapping chunks. At all times there is exactly one buffer actively storing values.

Parameters:
source - The Observable which produces values.
timespan - The amount of time all chunks must be actively collect values before being emitted.
unit - The TimeUnit defining the unit of time for the timespan.
count - The maximum size of the buffer. Once a buffer reaches this size, it is emitted.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       long timespan,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       int count,
                                                                       Scheduler scheduler)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. Additionally the buffer is automatically emitted once it reaches a specified number of elements. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation only produces non-overlapping chunks. At all times there is exactly one buffer actively storing values.

Parameters:
source - The Observable which produces values.
timespan - The amount of time all chunks must be actively collect values before being emitted.
unit - The TimeUnit defining the unit of time for the timespan.
count - The maximum size of the buffer. Once a buffer reaches this size, it is emitted.
scheduler - The Scheduler to use for timing chunks.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       long timespan,
                                                                       long timeshift,
                                                                       java.util.concurrent.TimeUnit unit)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. The creation of chunks is also periodical. How often this is done depends on the specified timeshift. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation can produce non-connected, or overlapping chunks depending on the input parameters.

Parameters:
source - The Observable which produces values.
timespan - The amount of time all chunks must be actively collect values before being emitted.
timeshift - The amount of time between creating chunks.
unit - The TimeUnit defining the unit of time for the timespan.
Returns:
the Func1 object representing the specified buffer operation.

buffer

public static <T> Observable.OnSubscribeFunc<java.util.List<T>> buffer(Observable<T> source,
                                                                       long timespan,
                                                                       long timeshift,
                                                                       java.util.concurrent.TimeUnit unit,
                                                                       Scheduler scheduler)

This method creates a Func1 object which represents the buffer operation. This operation takes values from the specified Observable source and stores them in a buffer. Periodically the buffer is emitted and replaced with a new buffer. How often this is done depends on the specified timespan. The creation of chunks is also periodical. How often this is done depends on the specified timeshift. When the source Observable completes or produces an error, the current buffer is emitted, and the event is propagated to all subscribed Observers.

Note that this operation can produce non-connected, or overlapping chunks depending on the input parameters.

Parameters:
source - The Observable which produces values.
timespan - The amount of time all chunks must be actively collect values before being emitted.
timeshift - The amount of time between creating chunks.
unit - The TimeUnit defining the unit of time for the timespan.
scheduler - The Scheduler to use for timing chunks.
Returns:
the Func1 object representing the specified buffer operation.