public final class Disposables extends Object
Modifier and Type | Method and Description |
---|---|
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.
|
@NonNull public static Disposable fromRunnable(@NonNull Runnable run)
run
- the Runnable to wrap@NonNull public static Disposable fromAction(@NonNull Action run)
run
- the Action to wrap@NonNull public static Disposable fromFuture(@NonNull Future<?> future)
future
- the Future to wrap@NonNull public static Disposable fromFuture(@NonNull Future<?> future, boolean allowInterrupt)
future
- the Future to wrapallowInterrupt
- if true, the future cancel happens via Future.cancel(true)@NonNull public static Disposable fromSubscription(@NonNull Subscription subscription)
subscription
- the Runnable to wrap@NonNull public static Disposable empty()
@NonNull public static Disposable disposed()