Top Description Inners Constructors Methods
rx.observables

public abstract Class AsyncOnSubscribe<S, T>

extends Object
implements Observable.OnSubscribe<T>
Class Inheritance
All Implemented Interfaces
rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action, rx.functions.Function
Known Direct Subclasses
rx.observables.AsyncOnSubscribe.AsyncOnSubscribeImpl
Annotations
@Beta
Type Parameters
<S>
the type of the user-define state used in generateState(S) , next(S, Long, Observer), and onUnsubscribe(S).
<T>
the type of Subscribers that will be compatible with this.
Imports
java.util.*, java.util.concurrent.atomic.AtomicBoolean, rx.*, .Observable, .Observable.OnSubscribe, .Observer, rx.annotations.Beta, rx.functions.*, rx.internal.operators.BufferUntilSubscriber, rx.observers.SerializedObserver, rx.plugins.RxJavaHooks, rx.subscriptions.CompositeSubscription

A utility class to create OnSubscribe<T> functions that respond correctly to back pressure requests from subscribers. This is an improvement over Observable.create(OnSubscribe) which does not provide any means of managing back pressure requests out-of-the-box. This variant of an OnSubscribe function allows for the asynchronous processing of requests.
Since
1.3 - beta

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
AsyncOnSubscribe.AsyncOnSubscribeImpl<
the type of the user-defined state
S
,
the type of compatible Subscribers
T
>

An implementation of AsyncOnSubscribe that delegates AsyncOnSubscribe#next(Object, long, Observer), AsyncOnSubscribe#generateState(), and AsyncOnSubscribe#onUnsubscribe(Object) to provided functions/closures.

pack-priv static class
pack-priv static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
call(final Subscriber<? super T> actualSubscriber)

Implements rx.functions.Action1.call.

public static <
the type of the associated state with each Subscriber
S
,
the type of the generated values
T
>
AsyncOnSubscribe<S, T>

Returns:

an AsyncOnSubscribe that emits data in a protocol compatible with back-pressure.
createSingleState
(Func0<? extends S>
generates the initial state value (see generateState())
generator
,
final Action3<? super S, Long, ? super Observer<Observable<? extends T>>>
produces data to the downstream subscriber (see next(S, long, Observer))
next
)

Generates a synchronous AsyncOnSubscribe that calls the provided next function to generate data to downstream subscribers.

public static <
the type of the associated state with each Subscriber
S
,
the type of the generated values
T
>
AsyncOnSubscribe<S, T>

Returns:

an AsyncOnSubscribe that emits data downstream in a protocol compatible with back-pressure.
createSingleState
(Func0<? extends S>
generates the initial state value (see generateState())
generator
,
final Action3<? super S, Long, ? super Observer<Observable<? extends T>>>
produces data to the downstream subscriber (see next(S, long, Observer))
next
,
final Action1<? super S>
clean up behavior (see onUnsubscribe(S))
onUnsubscribe
)

Generates a synchronous AsyncOnSubscribe that calls the provided next function to generate data to downstream subscribers.

public static <
the type of the associated state with each Subscriber
S
,
the type of the generated values
T
>
AsyncOnSubscribe<S, T>

Returns:

an AsyncOnSubscribe that emits data downstream in a protocol compatible with back-pressure.
createStateful
(Func0<? extends S>
generates the initial state value (see generateState())
generator
,
Func3<? super S, Long, ? super Observer<Observable<? extends T>>, ? extends S>
produces data to the downstream subscriber (see next(S, long, Observer))
next
,
Action1<? super S>
clean up behavior (see onUnsubscribe(S))
onUnsubscribe
)

Generates a synchronous AsyncOnSubscribe that calls the provided next function to generate data to downstream subscribers.

public static <
the type of the associated state with each Subscriber
S
,
the type of the generated values
T
>
AsyncOnSubscribe<S, T>

Returns:

an AsyncOnSubscribe that emits data downstream in a protocol compatible with back-pressure.
createStateful
(Func0<? extends S>
generates the initial state value (see generateState())
generator
,
Func3<? super S, Long, ? super Observer<Observable<? extends T>>, ? extends S>
produces data to the downstream subscriber (see next(S, long, Observer))
next
)

Generates a synchronous AsyncOnSubscribe that calls the provided next function to generate data to downstream subscribers.

public static <
the type of the generated values
T
>
AsyncOnSubscribe<Void, T>

Returns:

an AsyncOnSubscribe that emits data downstream in a protocol compatible with back-pressure.
createStateless
(final Action2<Long, ? super Observer<Observable<? extends T>>>
produces data to the downstream subscriber (see next(S, long, Observer))
next
)

Generates a synchronous AsyncOnSubscribe that calls the provided next function to generate data to downstream subscribers.

public static <
the type of the generated values
T
>
AsyncOnSubscribe<Void, T>

Returns:

an AsyncOnSubscribe that emits data downstream in a protocol compatible with back-pressure.
createStateless
(final Action2<Long, ? super Observer<Observable<? extends T>>>
produces data to the downstream subscriber (see next(S, long, Observer))
next
,
final Action0
clean up behavior (see onUnsubscribe(S))
onUnsubscribe
)

Generates a synchronous AsyncOnSubscribe that calls the provided next function to generate data to downstream subscribers.

protected abstract S

Returns:

the initial state value
generateState
()

Executed once when subscribed to by a subscriber (via call(Subscriber)) to produce a state value.

protected abstract S

Returns:

the next iteration's state value
next
(S
the state value (from generateState() on the first invocation or the previous invocation of this method.
state
,
long
the amount of data requested. An observable emitted to the observer should not exceed this amount.
requested
,
Observer<Observable<? extends T>>
the observer of data emitted by
observer
)

Called to produce data to the downstream subscribers.

protected void
onUnsubscribe(S
the last state value returned from next(S, Long, Observer) or generateState() at the time when a terminal event is emitted from next(Object, long, Observer) or unsubscribing.
state
)

Clean up behavior that is executed after the downstream subscriber's subscription is unsubscribed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait