Top Description Constructors Methods
io.reactivex.disposables

public final Class Disposables

extends Object
Class Inheritance
Imports
java.util.concurrent.Future, io.reactivex.annotations.NonNull, io.reactivex.functions.Action, io.reactivex.internal.disposables.EmptyDisposable, io.reactivex.internal.functions.*, org.reactivestreams.Subscription

Utility class to help create disposables by wrapping other types.
Since
2.0

Constructor Summary

AccessConstructor and Description
private
Disposables()

Utility class.

Method Summary

Modifier and TypeMethod and Description
public static Disposable

Returns:

a disposed Disposable instance
disposed
()

Returns a disposed Disposable instance.

public static Disposable

Returns:

a new, non-disposed Disposable instance
empty
()

Returns a new, non-disposed Disposable instance.

public static Disposable

Returns:

the new Disposable instance
fromAction
(Action
the Action to wrap
run
)

Construct a Disposable by wrapping a Action that is executed exactly once when the Disposable is disposed.

public static Disposable

Returns:

the new Disposable instance
fromFuture
(Future<?>
the Future to wrap
future
)

Construct a Disposable by wrapping a Future that is cancelled exactly once when the Disposable is disposed.

public static Disposable

Returns:

the new Disposable instance
fromFuture
(Future<?>
the Future to wrap
future
,
boolean
if true, the future cancel happens via Future.cancel(true)
allowInterrupt
)

Construct a Disposable by wrapping a Future that is cancelled exactly once when the Disposable is disposed.

public static Disposable

Returns:

the new Disposable instance
fromRunnable
(Runnable
the Runnable to wrap
run
)

Construct a Disposable by wrapping a Runnable that is executed exactly once when the Disposable is disposed.

public static Disposable

Returns:

the new Disposable instance
fromSubscription
(Subscription
the Runnable to wrap
subscription
)

Construct a Disposable by wrapping a Subscription that is cancelled exactly once when the Disposable is disposed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Disposablesback to summary
private Disposables()

Utility class.

Method Detail

disposedback to summary
public static Disposable disposed()

Returns a disposed Disposable instance.

Returns:Disposable

a disposed Disposable instance

Annotations
@NonNull
emptyback to summary
public static Disposable empty()

Returns a new, non-disposed Disposable instance.

Returns:Disposable

a new, non-disposed Disposable instance

Annotations
@NonNull
fromActionback to summary
public static Disposable fromAction(Action run)

Construct a Disposable by wrapping a Action that is executed exactly once when the Disposable is disposed.

Parameters
run:Action

the Action to wrap

Returns:Disposable

the new Disposable instance

Annotations
@NonNull
fromFutureback to summary
public static Disposable fromFuture(Future<?> future)

Construct a Disposable by wrapping a Future that is cancelled exactly once when the Disposable is disposed.

Parameters
future:Future<?>

the Future to wrap

Returns:Disposable

the new Disposable instance

Annotations
@NonNull
fromFutureback to summary
public static Disposable fromFuture(Future<?> future, boolean allowInterrupt)

Construct a Disposable by wrapping a Future that is cancelled exactly once when the Disposable is disposed.

Parameters
future:Future<?>

the Future to wrap

allowInterrupt:boolean

if true, the future cancel happens via Future.cancel(true)

Returns:Disposable

the new Disposable instance

Annotations
@NonNull
fromRunnableback to summary
public static Disposable fromRunnable(Runnable run)

Construct a Disposable by wrapping a Runnable that is executed exactly once when the Disposable is disposed.

Parameters
run:Runnable

the Runnable to wrap

Returns:Disposable

the new Disposable instance

Annotations
@NonNull
fromSubscriptionback to summary
public static Disposable fromSubscription(Subscription subscription)

Construct a Disposable by wrapping a Subscription that is cancelled exactly once when the Disposable is disposed.

Parameters
subscription:Subscription

the Runnable to wrap

Returns:Disposable

the new Disposable instance

Annotations
@NonNull