Top Description Inners Fields Constructors Methods
rx.subscriptions

public final Class Subscriptions

extends Object
Class Inheritance
Imports
java.util.concurrent.Future, rx.Subscription, rx.functions.Action0

Helper methods and utilities for creating and working with Subscription objects

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
Subscriptions.FutureSubscription

Naming classes helps with debugging.

pack-priv static class
Subscriptions.Unsubscribed

Naming classes helps with debugging.

Field Summary

Modifier and TypeField and Description
private static final Subscriptions.Unsubscribed
UNSUBSCRIBED

A Subscription that does nothing when its unsubscribe method is called.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Subscription

Returns:

Subscription
create
(final Action0
Action to invoke on unsubscribe.
unsubscribe
)

Creates and returns a Subscription that invokes the given Action0 when unsubscribed.

public static Subscription

Returns:

a Subscription to which unsubscribe does nothing except to change isUnsubscribed to true
empty
()

Returns a Subscription to which unsubscribe does nothing except to change isUnsubscribed to true.

public static Subscription

Returns:

a Subscription that wraps f
from
(final Future<?>
the Future to convert
f
)

Converts a Future into a Subscription and cancels it when unsubscribed.

public static CompositeSubscription

Returns:

a CompositeSubscription representing the subscriptions set
from
(Subscription...
the Subscriptions to group together
subscriptions
)

Converts a set of Subscriptions into a CompositeSubscription that groups the multiple Subscriptions together and unsubscribes from all of them together.

public static Subscription

Returns:

a Subscription to which unsubscribe does nothing, as it is already unsubscribed
unsubscribed
()

Returns a Subscription to which unsubscribe does nothing, as it is already unsubscribed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

UNSUBSCRIBEDback to summary
private static final Subscriptions.Unsubscribed UNSUBSCRIBED

A Subscription that does nothing when its unsubscribe method is called.

Constructor Detail

Subscriptionsback to summary
private Subscriptions()

Method Detail

createback to summary
public static Subscription create(final Action0 unsubscribe)

Creates and returns a Subscription that invokes the given Action0 when unsubscribed.

Parameters
unsubscribe:Action0

Action to invoke on unsubscribe.

Returns:Subscription

Subscription

emptyback to summary
public static Subscription empty()

Returns a Subscription to which unsubscribe does nothing except to change isUnsubscribed to true. It's stateful and isUnsubscribed indicates if unsubscribe is called, which is different from unsubscribed().


Subscription empty = Subscriptions.empty();
System.out.println(empty.isUnsubscribed()); // false
empty.unsubscribe();
System.out.println(empty.isUnsubscribed()); // true
Returns:Subscription

a Subscription to which unsubscribe does nothing except to change isUnsubscribed to true

fromback to summary
public static Subscription from(final Future<?> f)

Converts a Future into a Subscription and cancels it when unsubscribed.

Parameters
f:Future<?>

the Future to convert

Returns:Subscription

a Subscription that wraps f

fromback to summary
public static CompositeSubscription from(Subscription... subscriptions)

Converts a set of Subscriptions into a CompositeSubscription that groups the multiple Subscriptions together and unsubscribes from all of them together.

Parameters
subscriptions:Subscription[]

the Subscriptions to group together

Returns:CompositeSubscription

a CompositeSubscription representing the subscriptions set

unsubscribedback to summary
public static Subscription unsubscribed()

Returns a Subscription to which unsubscribe does nothing, as it is already unsubscribed. Its isUnsubscribed always returns true, which is different from empty().


Subscription unsubscribed = Subscriptions.unsubscribed();
System.out.println(unsubscribed.isUnsubscribed()); // true
Returns:Subscription

a Subscription to which unsubscribe does nothing, as it is already unsubscribed

Since
1.1.0
rx.subscriptions back to summary

pack-priv final Class Subscriptions.FutureSubscription

extends Object
implements Subscription
Class Inheritance
All Implemented Interfaces
rx.Subscription

Naming classes helps with debugging.

Field Summary

Modifier and TypeField and Description
pack-priv final Future<?>
f

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fback to summary
pack-priv final Future<?> f

Constructor Detail

FutureSubscriptionback to summary
public FutureSubscription(Future<?> f)

Method Detail

isUnsubscribedback to summary
public boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
unsubscribeback to summary
public void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

This allows deregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

Annotations
@Override
rx.subscriptions back to summary

pack-priv final Class Subscriptions.Unsubscribed

extends Object
implements Subscription
Class Inheritance
All Implemented Interfaces
rx.Subscription

Naming classes helps with debugging.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Unsubscribedback to summary
pack-priv Unsubscribed()

Method Detail

isUnsubscribedback to summary
public boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
unsubscribeback to summary
public void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

This allows deregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

Annotations
@Override