Top Description Constructors Methods
rx.observers

public final Class Subscribers

extends Object
Class Inheritance
Imports
rx.*, rx.exceptions.OnErrorNotImplementedException, rx.functions.*

Helper methods and utilities for creating and working with Subscriber objects.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <
the observed value type
T
>
Subscriber<T>

Returns:

a Subscriber that calls onNext for each emitted item from the Observable the Subscriber subscribes to
create
(final Action1<? super T>
a function that handles each item emitted by an Observable
onNext
)

Creates a Subscriber that receives the emissions of any Observable it subscribes to via onNext but ignores onCompleted notifications; it will throw an OnErrorNotImplementedException if onError is invoked.

public static <
the observed value type
T
>
Subscriber<T>

Returns:

an Subscriber that calls onNext for each emitted item from the Observable the Subscriber subscribes to, and calls onError if the Observable notifies of an error
create
(final Action1<? super T>
a function that handles each item emitted by an Observable
onNext
,
final Action1<Throwable>
a function that handles an error notification if one is sent by an Observable
onError
)

Creates an Subscriber that receives the emissions of any Observable it subscribes to via onNext and handles any onError notification but ignores an onCompleted notification.

public static <
the observed value type
T
>
Subscriber<T>

Returns:

an Subscriber that calls onNext for each emitted item from the Observable the Subscriber subscribes to, calls onError if the Observable notifies of an error, and calls onComplete if the Observable notifies that the observable sequence is complete
create
(final Action1<? super T>
a function that handles each item emitted by an Observable
onNext
,
final Action1<Throwable>
a function that handles an error notification if one is sent by an Observable
onError
,
final Action0
a function that handles a sequence complete notification if one is sent by an Observable
onComplete
)

Creates an Subscriber that receives the emissions of any Observable it subscribes to via onNext and handles any onError or onCompleted notifications.

public static <
the observed value type
T
>
Subscriber<T>

Returns:

an inert Observer
empty
()

Returns an inert Subscriber that does nothing in response to the emissions or notifications from any Observable it subscribes to.

public static <
the observed value type
T
>
Subscriber<T>

Returns:

a Subscriber version of o
from
(final Observer<? super T>
the Observer to convert
o
)

Converts an Observer into a Subscriber.

public static <
the observed value type
T
>
Subscriber<T>

Returns:

a new Subscriber that passes all events to subscriber, has backpressure controlled by subscriber and uses subscriber to manage unsubscription.
wrap
(final Subscriber<? super T>
the Subscriber to wrap.
subscriber
)

Returns a new Subscriber that passes all events to subscriber, has backpressure controlled by subscriber and uses the subscription list of subscriber when Subscriber#add(rx.Subscription) is called.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Subscribersback to summary
private Subscribers()

Method Detail

createback to summary
public static <T> Subscriber<T> create(final Action1<? super T> onNext)

Creates a Subscriber that receives the emissions of any Observable it subscribes to via onNext but ignores onCompleted notifications; it will throw an OnErrorNotImplementedException if onError is invoked.

Parameters
<T>
the observed value type
onNext:Action1<? super T>

a function that handles each item emitted by an Observable

Returns:Subscriber<T>

a Subscriber that calls onNext for each emitted item from the Observable the Subscriber subscribes to

Exceptions
IllegalArgumentException:
if onNext is null
createback to summary
public static <T> Subscriber<T> create(final Action1<? super T> onNext, final Action1<Throwable> onError)

Creates an Subscriber that receives the emissions of any Observable it subscribes to via onNext and handles any onError notification but ignores an onCompleted notification.

Parameters
<T>
the observed value type
onNext:Action1<? super T>

a function that handles each item emitted by an Observable

onError:Action1<Throwable>

a function that handles an error notification if one is sent by an Observable

Returns:Subscriber<T>

an Subscriber that calls onNext for each emitted item from the Observable the Subscriber subscribes to, and calls onError if the Observable notifies of an error

Exceptions
IllegalArgumentException:
if either onNext or onError are null
createback to summary
public static <T> Subscriber<T> create(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete)

Creates an Subscriber that receives the emissions of any Observable it subscribes to via onNext and handles any onError or onCompleted notifications.

Parameters
<T>
the observed value type
onNext:Action1<? super T>

a function that handles each item emitted by an Observable

onError:Action1<Throwable>

a function that handles an error notification if one is sent by an Observable

onComplete:Action0

a function that handles a sequence complete notification if one is sent by an Observable

Returns:Subscriber<T>

an Subscriber that calls onNext for each emitted item from the Observable the Subscriber subscribes to, calls onError if the Observable notifies of an error, and calls onComplete if the Observable notifies that the observable sequence is complete

Exceptions
IllegalArgumentException:
if either onNext, onError, or onComplete are null
emptyback to summary
public static <T> Subscriber<T> empty()

Returns an inert Subscriber that does nothing in response to the emissions or notifications from any Observable it subscribes to. Will throw an OnErrorNotImplementedException if onError method is called

Parameters
<T>
the observed value type
Returns:Subscriber<T>

an inert Observer

fromback to summary
public static <T> Subscriber<T> from(final Observer<? super T> o)

Converts an Observer into a Subscriber.

Parameters
<T>
the observed value type
o:Observer<? super T>

the Observer to convert

Returns:Subscriber<T>

a Subscriber version of o

wrapback to summary
public static <T> Subscriber<T> wrap(final Subscriber<? super T> subscriber)

Returns a new Subscriber that passes all events to subscriber, has backpressure controlled by subscriber and uses the subscription list of subscriber when Subscriber#add(rx.Subscription) is called.

Parameters
<T>
the observed value type
subscriber:Subscriber<? super T>

the Subscriber to wrap.

Returns:Subscriber<T>

a new Subscriber that passes all events to subscriber, has backpressure controlled by subscriber and uses subscriber to manage unsubscription.

Since
1.1.0