RxJava



rx.operators
Class OperationWindow

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

public final class OperationWindow
extends ChunkedOperation


Nested Class Summary
protected static class OperationWindow.Window<T>
          This class represents a single window: 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
OperationWindow()
           
 
Method Summary
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, Func0<? extends Observable<? extends Closing>> windowClosingSelector)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, int count)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, int count, int skip)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, long timespan, long timeshift, java.util.concurrent.TimeUnit unit)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, long timespan, long timeshift, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, long timespan, java.util.concurrent.TimeUnit unit)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, long timespan, java.util.concurrent.TimeUnit unit, int count)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, long timespan, java.util.concurrent.TimeUnit unit, int count, Scheduler scheduler)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, long timespan, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
          This method creates a Func1 object which represents the window operation.
static
<T> Observable.OnSubscribeFunc<Observable<T>>
window(Observable<? extends T> source, Observable<? extends Opening> windowOpenings, Func1<Opening,? extends Observable<? extends Closing>> windowClosingSelector)
          This method creates a Func1 object which represents the window operation.
static
<T> Func0<OperationWindow.Window<T>>
windowMaker()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationWindow

public OperationWindow()
Method Detail

windowMaker

public static <T> Func0<OperationWindow.Window<T>> windowMaker()

window

public static <T> Observable.OnSubscribeFunc<Observable<T>> window(Observable<? extends T> source,
                                                                   Func0<? extends Observable<? extends Closing>> windowClosingSelector)

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

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

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

window

public static <T> Observable.OnSubscribeFunc<Observable<T>> window(Observable<? extends T> source,
                                                                   Observable<? extends Opening> windowOpenings,
                                                                   Func1<Opening,? extends Observable<? extends Closing>> windowClosingSelector)

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

Windows can be created by pushing a Opening value to the "windowOpenings" Observable. This creates a new window which will then start recording values which are produced by the "source" Observable. Additionally the "windowClosingSelector" 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 window. When the source Observable completes or produces an error, all windows are emitted, and the event is propagated to all subscribed Observers.

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

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

window

public static <T> Observable.OnSubscribeFunc<Observable<T>> window(Observable<? extends T> source,
                                                                   int count)

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

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

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

window

public static <T> Observable.OnSubscribeFunc<Observable<T>> window(Observable<? extends T> source,
                                                                   int count,
                                                                   int skip)

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

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

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

window

public static <T> Observable.OnSubscribeFunc<Observable<T>> window(Observable<? extends T> source,
                                                                   long timespan,
                                                                   java.util.concurrent.TimeUnit unit)

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

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

Parameters:
source - The Observable which produces values.
timespan - The amount of time all windows 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 window operation.

window

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

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

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

Parameters:
source - The Observable which produces values.
timespan - The amount of time all windows 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 windows.
Returns:
the Func1 object representing the specified window operation.

window

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

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

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

Parameters:
source - The Observable which produces values.
timespan - The amount of time all windows 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 window. Once a window reaches this size, it is emitted.
Returns:
the Func1 object representing the specified window operation.

window

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

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

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

Parameters:
source - The Observable which produces values.
timespan - The amount of time all windows 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 window. Once a window reaches this size, it is emitted.
scheduler - The Scheduler to use for timing windows.
Returns:
the Func1 object representing the specified window operation.

window

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

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

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

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

window

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

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

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

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