public final class CompositeDisposable extends Object implements Disposable, DisposableContainer
Constructor and Description |
---|
CompositeDisposable()
Creates an empty CompositeDisposable.
|
CompositeDisposable(Disposable... disposables)
Creates a CompositeDisposables with the given array of initial elements.
|
CompositeDisposable(@NonNull Iterable<? extends Disposable> disposables)
Creates a CompositeDisposables with the given Iterable sequence of initial elements.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(@NonNull Disposable disposable)
Adds a disposable to this container or disposes it if the
container has been disposed.
|
boolean |
addAll(Disposable... disposables)
Atomically adds the given array of Disposables to the container or
disposes them all if the container has been disposed.
|
void |
clear()
Atomically clears the container, then disposes all the previously contained Disposables.
|
boolean |
delete(@NonNull Disposable disposable)
Removes (but does not dispose) the given disposable if it is part of this
container.
|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
boolean |
remove(@NonNull Disposable disposable)
Removes and disposes the given disposable if it is part of this
container.
|
int |
size()
Returns the number of currently held Disposables.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disposed, empty, fromAction, fromAutoCloseable, fromFuture, fromFuture, fromRunnable, fromSubscription, toAutoCloseable
public CompositeDisposable()
public CompositeDisposable(@NonNull Disposable... disposables)
disposables
- the array of Disposables to start withNullPointerException
- if disposables
or any of its array items is null
public CompositeDisposable(@NonNull @NonNull Iterable<? extends Disposable> disposables)
disposables
- the Iterable sequence of Disposables to start withNullPointerException
- if disposables
or any of its items is null
public void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable
public boolean add(@NonNull @NonNull Disposable disposable)
add
in interface DisposableContainer
disposable
- the disposable to add, not nullNullPointerException
- if disposable
is null
public boolean addAll(@NonNull Disposable... disposables)
disposables
- the array of DisposablesNullPointerException
- if disposables
or any of its array items is null
public boolean remove(@NonNull @NonNull Disposable disposable)
remove
in interface DisposableContainer
disposable
- the disposable to remove and dispose, not nullpublic boolean delete(@NonNull @NonNull Disposable disposable)
delete
in interface DisposableContainer
disposable
- the disposable to remove, not nullNullPointerException
- if disposable
is null
public void clear()
public int size()