public final class

Disposables

extends Object
java.lang.Object
   ↳ io.reactivex.disposables.Disposables

Class Overview

Utility class to help create disposables by wrapping other types.

Summary

Public Methods
static Disposable disposed()
Returns a disposed Disposable instance.
static Disposable empty()
Returns a new, non-disposed Disposable instance.
static Disposable fromAction(Action run)
Construct a Disposable by wrapping a Action that is executed exactly once when the Disposable is disposed.
static Disposable fromFuture(Future<?> future)
Construct a Disposable by wrapping a Future that is cancelled exactly once when the Disposable is disposed.
static Disposable fromFuture(Future<?> future, boolean allowInterrupt)
Construct a Disposable by wrapping a Future that is cancelled exactly once when the Disposable is disposed.
static Disposable fromRunnable(Runnable run)
Construct a Disposable by wrapping a Runnable that is executed exactly once when the Disposable is disposed.
static Disposable fromSubscription(Subscription subscription)
Construct a Disposable by wrapping a Subscription that is cancelled exactly once when the Disposable is disposed.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static Disposable disposed ()

Returns a disposed Disposable instance.

Returns
  • a disposed Disposable instance

public static Disposable empty ()

Returns a new, non-disposed Disposable instance.

Returns
  • a new, non-disposed Disposable instance

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 the Action to wrap
Returns
  • the new Disposable instance

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 the Future to wrap
Returns
  • the new Disposable instance

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 the Future to wrap
allowInterrupt if true, the future cancel happens via Future.cancel(true)
Returns
  • the new Disposable instance

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 the Runnable to wrap
Returns
  • the new Disposable instance

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 the Runnable to wrap
Returns
  • the new Disposable instance