Package rx.observables
Class AsyncOnSubscribe.AsyncOnSubscribeImpl<S,T>
- java.lang.Object
-
- rx.observables.AsyncOnSubscribe<S,T>
-
- rx.observables.AsyncOnSubscribe.AsyncOnSubscribeImpl<S,T>
-
- Type Parameters:
S- the type of the user-defined stateT- the type of compatible Subscribers
- All Implemented Interfaces:
Action,Action1<Subscriber<? super T>>,Function,Observable.OnSubscribe<T>
- Enclosing class:
- AsyncOnSubscribe<S,T>
static final class AsyncOnSubscribe.AsyncOnSubscribeImpl<S,T> extends AsyncOnSubscribe<S,T>
An implementation of AsyncOnSubscribe that delegatesAsyncOnSubscribe.next(Object, long, Observer),AsyncOnSubscribe.generateState(), andAsyncOnSubscribe.onUnsubscribe(Object)to provided functions/closures.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class rx.observables.AsyncOnSubscribe
AsyncOnSubscribe.AsyncOnSubscribeImpl<S,T>, AsyncOnSubscribe.AsyncOuterManager<S,T>, AsyncOnSubscribe.UnicastSubject<T>
-
-
Constructor Summary
Constructors Constructor Description AsyncOnSubscribeImpl(Func0<? extends S> generator, Func3<? super S,java.lang.Long,? super Observer<Observable<? extends T>>,? extends S> next)AsyncOnSubscribeImpl(Func0<? extends S> generator, Func3<? super S,java.lang.Long,? super Observer<Observable<? extends T>>,? extends S> next, Action1<? super S> onUnsubscribe)AsyncOnSubscribeImpl(Func3<S,java.lang.Long,Observer<Observable<? extends T>>,S> nextFunc)AsyncOnSubscribeImpl(Func3<S,java.lang.Long,Observer<Observable<? extends T>>,S> next, Action1<? super S> onUnsubscribe)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SgenerateState()Executed once when subscribed to by a subscriber (viaAsyncOnSubscribe.call(Subscriber)) to produce a state value.protected Snext(S state, long requested, Observer<Observable<? extends T>> observer)Called to produce data to the downstream subscribers.protected voidonUnsubscribe(S state)Clean up behavior that is executed after the downstream subscriber's subscription is unsubscribed.-
Methods inherited from class rx.observables.AsyncOnSubscribe
call, createSingleState, createSingleState, createStateful, createStateful, createStateless, createStateless
-
-
-
-
Constructor Detail
-
AsyncOnSubscribeImpl
AsyncOnSubscribeImpl(Func0<? extends S> generator, Func3<? super S,java.lang.Long,? super Observer<Observable<? extends T>>,? extends S> next, Action1<? super S> onUnsubscribe)
-
AsyncOnSubscribeImpl
public AsyncOnSubscribeImpl(Func0<? extends S> generator, Func3<? super S,java.lang.Long,? super Observer<Observable<? extends T>>,? extends S> next)
-
AsyncOnSubscribeImpl
public AsyncOnSubscribeImpl(Func3<S,java.lang.Long,Observer<Observable<? extends T>>,S> next, Action1<? super S> onUnsubscribe)
-
-
Method Detail
-
generateState
protected S generateState()
Description copied from class:AsyncOnSubscribeExecuted once when subscribed to by a subscriber (viaAsyncOnSubscribe.call(Subscriber)) to produce a state value. This value is passed intonext(S state, Observeron the first iteration. Subsequent iterations ofobserver) nextwill receive the state returned by the previous invocation ofnext.- Specified by:
generateStatein classAsyncOnSubscribe<S,T>- Returns:
- the initial state value
-
next
protected S next(S state, long requested, Observer<Observable<? extends T>> observer)
Description copied from class:AsyncOnSubscribeCalled to produce data to the downstream subscribers. To emit data to a downstream subscriber callobserver.onNext(t). To signal an error condition callobserver.onError(throwable)or throw an Exception. To signal the end of a data stream callobserver.onCompleted(). Implementations of this method must follow the following rules.- Must not call
observer.onNext(t)more than 1 time per invocation. - Must not call
observer.onNext(t)concurrently.
stateargument of the next invocation of this method.- Specified by:
nextin classAsyncOnSubscribe<S,T>- Parameters:
state- the state value (fromAsyncOnSubscribe.generateState()on the first invocation or the previous invocation of this method.requested- the amount of data requested. An observable emitted to the observer should not exceed this amount.observer- the observer of data emitted by- Returns:
- the next iteration's state value
- Must not call
-
onUnsubscribe
protected void onUnsubscribe(S state)
Description copied from class:AsyncOnSubscribeClean up behavior that is executed after the downstream subscriber's subscription is unsubscribed. This method will be invoked exactly once.- Overrides:
onUnsubscribein classAsyncOnSubscribe<S,T>- Parameters:
state- the last state value returned fromnext(S, Long, Observer)orgenerateState()at the time when a terminal event is emitted fromAsyncOnSubscribe.next(Object, long, Observer)or unsubscribing.
-
-