public final class Transformers extends Object
| Constructor and Description |
|---|
Transformers() |
| Modifier and Type | Method and Description |
|---|---|
static <T> rx.Observable.Transformer<T,T> |
bufferEmissions() |
static <T extends Number> |
collectStats() |
static <T,R extends Number> |
collectStats(rx.functions.Func1<? super T,? extends R> function) |
static <T,R extends Collection<T>> |
collectWhile(rx.functions.Func0<R> factory,
rx.functions.Action2<? super R,? super T> collect)
Returns a
Observable.Transformer that returns an Observable that is
collected into Collection instances created by factory
that are emitted when items are not equal or on completion. |
static <T,R extends Collection<T>> |
collectWhile(rx.functions.Func0<R> factory,
rx.functions.Action2<? super R,? super T> collect,
rx.functions.Func2<? super R,? super T,Boolean> condition)
Returns a
Observable.Transformer that returns an Observable that is
collected into Collection instances created by factory
that are emitted when the collection and latest emission do not satisfy
condition or on completion. |
static <T> rx.Observable.Transformer<T,T> |
doOnFirst(rx.functions.Action1<? super T> action)
Returns a
Observable.Transformer that applied to a source Observable
calls the given action on the first onNext emission. |
static <T> rx.Observable.Transformer<T,T> |
doOnNext(int n,
rx.functions.Action1<? super T> action)
Returns a
Observable.Transformer that applied to a source Observable
calls the given action on the nth onNext emission. |
static <R,T> rx.Observable.Transformer<T,R> |
ignoreElementsThen(rx.Observable<R> next) |
static <T> rx.Observable.Transformer<T,MapWithIndex.Indexed<T>> |
mapWithIndex() |
static <T> rx.Observable.Transformer<T,T> |
orderedMergeWith(rx.Observable<T> other,
rx.functions.Func2<? super T,? super T,Integer> comparator)
Returns the source
Observable merged with the other
observable using the given Comparator for order. |
static <T extends Comparable<? super T>> |
sort() |
static <T> rx.Observable.Transformer<T,T> |
sort(Comparator<? super T> comparator) |
static <T> rx.Observable.Transformer<String,String> |
split(String pattern) |
static <State,In,Out> |
stateMachine(rx.functions.Func0<State> initialStateFactory,
rx.functions.Func3<? super State,? super In,? super rx.Subscriber<Out>,? extends State> transition,
rx.functions.Action2<? super State,? super rx.Subscriber<Out>> completionAction)
Returns a
Observable.Transformer that allows processing of the source stream
to be defined in a state machine where transitions of the state machine
may also emit items to downstream that are buffered if necessary when
backpressure is requested. |
static <State,In,Out> |
stateMachine(State initialState,
rx.functions.Func3<? super State,? super In,? super rx.Subscriber<Out>,? extends State> transition)
Returns a
Observable.Transformer that allows processing of the source stream
to be defined in a state machine where transitions of the state machine
may also emit items to downstream that are buffered if necessary when
backpressure is requested. |
static <State,In,Out> |
stateMachine(State initialState,
rx.functions.Func3<? super State,? super In,? super rx.Subscriber<Out>,? extends State> transition,
rx.functions.Action2<? super State,? super rx.Subscriber<Out>> completionAction)
Returns a
Observable.Transformer that allows processing of the source stream
to be defined in a state machine where transitions of the state machine
may also emit items to downstream that are buffered if necessary when
backpressure is requested. |
static <T> rx.Observable.Transformer<T,List<T>> |
toListUntilChanged()
Returns a
Observable.Transformer that returns an Observable that is
a buffering of the source Observable into lists of sequential items that
are equal. |
static <T> rx.Observable.Transformer<T,List<T>> |
toListWhile(rx.functions.Func2<? super List<T>,? super T,Boolean> condition)
Returns a
Observable.Transformer that returns an Observable that is
a buffering of the source Observable into lists of sequential items that
satisfy the condition condition. |
static <T,R> rx.Observable.Operator<R,T> |
toOperator(rx.functions.Func1<? super rx.Observable<T>,? extends rx.Observable<R>> function) |
static <T> rx.Observable.Transformer<T,Set<T>> |
toSet() |
public static <T,R> rx.Observable.Operator<R,T> toOperator(rx.functions.Func1<? super rx.Observable<T>,? extends rx.Observable<R>> function)
public static <T extends Number> rx.Observable.Transformer<T,Statistics> collectStats()
public static <T,R extends Number> rx.Observable.Transformer<T,Pair<T,Statistics>> collectStats(rx.functions.Func1<? super T,? extends R> function)
public static <T extends Comparable<? super T>> rx.Observable.Transformer<T,T> sort()
public static <T> rx.Observable.Transformer<T,T> sort(Comparator<? super T> comparator)
public static <T> rx.Observable.Transformer<T,Set<T>> toSet()
public static <T> rx.Observable.Transformer<T,MapWithIndex.Indexed<T>> mapWithIndex()
public static <State,In,Out> rx.Observable.Transformer<In,Out> stateMachine(rx.functions.Func0<State> initialStateFactory,
rx.functions.Func3<? super State,? super In,? super rx.Subscriber<Out>,? extends State> transition,
rx.functions.Action2<? super State,? super rx.Subscriber<Out>> completionAction)
Observable.Transformer that allows processing of the source stream
to be defined in a state machine where transitions of the state machine
may also emit items to downstream that are buffered if necessary when
backpressure is requested. flatMap is part of the processing
chain so the source may experience requests for more items than are
strictly required by the endpoint subscriber.
Internally this transformer uses Observable.scan(rx.functions.Func2<T, T, T>) emitting a
stream of new states composed with emissions from the transition to each
state and Observable.flatMap(rx.functions.Func1<? super T, ? extends rx.Observable<? extends R>>) to emit the recorded emissions with
backpressure.
State - the class representing the state of the state machineIn - the input observable typeOut - the output observable typeinitialStateFactory - the factory to create the initial state of the state machine.transition - defines state transitions and consequent emissions to
downstream when an item arrives from upstream. The
Subscriber is called with the emissions to downstream.
You can optionally call Subscriber.isUnsubscribed() to
check if you can stop emitting from the transition. If you do
wish to terminate the transition due to unsubscription then
return null from the transition.completionAction - defines activity that should happen based on the final state
just before downstream onCompleted() is called.
For example any buffered emissions in state could be emitted
at this point. Don't call observer.onCompleted()
as it is called for you after the action completes.NullPointerException - if initialStateFactory or transition,or
completionAction is nullpublic static <State,In,Out> rx.Observable.Transformer<In,Out> stateMachine(State initialState,
rx.functions.Func3<? super State,? super In,? super rx.Subscriber<Out>,? extends State> transition,
rx.functions.Action2<? super State,? super rx.Subscriber<Out>> completionAction)
Observable.Transformer that allows processing of the source stream
to be defined in a state machine where transitions of the state machine
may also emit items to downstream that are buffered if necessary when
backpressure is requested. flatMap is part of the processing
chain so the source may experience requests for more items than are
strictly required by the endpoint subscriber.
Internally this transformer uses Observable.scan(rx.functions.Func2<T, T, T>) emitting a
stream of new states composed with emissions from the transition to each
state and Observable.flatMap(rx.functions.Func1<? super T, ? extends rx.Observable<? extends R>>) to emit the recorded emissions with
backpressure.
State - the class representing the state of the state machineIn - the input observable typeOut - the output observable typeinitialState - the initial state of the state machine.transition - defines state transitions and consequent emissions to
downstream when an item arrives from upstream. The
Subscriber is called with the emissions to downstream.
You can optionally call Subscriber.isUnsubscribed() to
check if you can stop emitting from the transition. If you do
wish to terminate the transition due to unsubscription then
return null from the transition.completionAction - defines activity that should happen based on the final state
just before downstream onCompleted() is called.
For example any buffered emissions in state could be emitted
at this point. Don't call observer.onCompleted()
as it is called for you after the action completes.NullPointerException - if transition or completionAction is nullpublic static <State,In,Out> rx.Observable.Transformer<In,Out> stateMachine(State initialState,
rx.functions.Func3<? super State,? super In,? super rx.Subscriber<Out>,? extends State> transition)
Observable.Transformer that allows processing of the source stream
to be defined in a state machine where transitions of the state machine
may also emit items to downstream that are buffered if necessary when
backpressure is requested. flatMap is part of the processing
chain so the source may experience requests for more items than are
strictly required by the endpoint subscriber. This overload uses a do
nothing completionAction which may leave some emissions recorded
in State as unemitted.
Internally this transformer uses Observable.scan(rx.functions.Func2<T, T, T>) emitting a
stream of new states composed with emissions from the transition to each
state and Observable.flatMap(rx.functions.Func1<? super T, ? extends rx.Observable<? extends R>>) to emit the recorded emissions with
backpressure.
State - the class representing the state of the state machineIn - the input observable typeOut - the output observable typeinitialState - the initial state of the state machine.transition - defines state transitions and consequent emissions to
downstream when an item arrives from upstream. The
Subscriber is called with the emissions to downstream.
You can optionally call Subscriber.isUnsubscribed() to
check if you can stop emitting from the transition. If you do
wish to terminate the transition due to unsubscription then
return null from the transition.NullPointerException - if initialState or transition is nullpublic static <T> rx.Observable.Transformer<T,T> bufferEmissions()
public static final <T> rx.Observable.Transformer<T,T> orderedMergeWith(rx.Observable<T> other,
rx.functions.Func2<? super T,? super T,Integer> comparator)
Observable merged with the other
observable using the given Comparator for order. A precondition
is that the source and other are already ordered. This transformer does
not support backpressure but its inputs must support backpressure. If you
need backpressure support then compose with
.onBackpressureXXX.T - the generic type of the objects being comparedother - the other already ordered observablecomparator - the ordering to usepublic static <T> rx.Observable.Transformer<T,List<T>> toListUntilChanged()
Observable.Transformer that returns an Observable that is
a buffering of the source Observable into lists of sequential items that
are equal.
For example, the stream
Observable.just(1, 1, 2, 2, 1).compose(toListUntilChanged())
would emit [1,1], [2], [1].
T - the generic type of the source Observablepublic static <T> rx.Observable.Transformer<T,List<T>> toListWhile(rx.functions.Func2<? super List<T>,? super T,Boolean> condition)
Observable.Transformer that returns an Observable that is
a buffering of the source Observable into lists of sequential items that
satisfy the condition condition.T - the generic type of the source Observablecondition - condition function that must return true if an item is to be
part of the list being prepared for emissionpublic static <T,R extends Collection<T>> rx.Observable.Transformer<T,R> collectWhile(rx.functions.Func0<R> factory, rx.functions.Action2<? super R,? super T> collect)
Observable.Transformer that returns an Observable that is
collected into Collection instances created by factory
that are emitted when items are not equal or on completion.T - generic type of source observableR - collection type emitted by transformed Observablefactory - collection instance creatorcollect - collection actionpublic static <T,R extends Collection<T>> rx.Observable.Transformer<T,R> collectWhile(rx.functions.Func0<R> factory, rx.functions.Action2<? super R,? super T> collect, rx.functions.Func2<? super R,? super T,Boolean> condition)
Observable.Transformer that returns an Observable that is
collected into Collection instances created by factory
that are emitted when the collection and latest emission do not satisfy
condition or on completion.T - generic type of source observableR - collection type emitted by transformed Observablefactory - collection instance creatorcollect - collection actioncondition - returns true if and only if emission should be collected in
current collection being prepared for emissionpublic static <T> rx.Observable.Transformer<T,T> doOnNext(int n,
rx.functions.Action1<? super T> action)
Observable.Transformer that applied to a source Observable
calls the given action on the nth onNext emission.n - the 1-based count of onNext to do the action onaction - is performed on nth onNext.public static <T> rx.Observable.Transformer<T,T> doOnFirst(rx.functions.Action1<? super T> action)
Observable.Transformer that applied to a source Observable
calls the given action on the first onNext emission.action - is performed on first onNext.public static <R,T> rx.Observable.Transformer<T,R> ignoreElementsThen(rx.Observable<R> next)
Copyright © 2013–2015. All rights reserved.