public final class CompositeDisposable extends Object implements Disposable, io.reactivex.rxjava3.internal.disposables.DisposableContainer
Constructor and Description |
---|
CompositeDisposable()
Creates an empty CompositeDisposable.
|
CompositeDisposable(Disposable... disposables)
Creates a CompositeDisposables with the given array of initial elements.
|
CompositeDisposable(Iterable<? extends Disposable> disposables)
Creates a CompositeDisposables with the given Iterable sequence of initial elements.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(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(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(Disposable disposable)
Removes and disposes the given disposable if it is part of this
container.
|
int |
size()
Returns the number of currently held Disposables.
|
public CompositeDisposable()
public CompositeDisposable(@NonNull Disposable... disposables)
disposables
- the array of Disposables to start withNullPointerException
- if disposables
or any of its array items is nullpublic CompositeDisposable(@NonNull Iterable<? extends Disposable> disposables)
disposables
- the Iterable sequence of Disposables to start withNullPointerException
- if disposables
or any of its items is nullpublic void dispose()
Disposable
dispose
in interface Disposable
public boolean isDisposed()
Disposable
isDisposed
in interface Disposable
public boolean add(@NonNull Disposable disposable)
add
in interface io.reactivex.rxjava3.internal.disposables.DisposableContainer
disposable
- the disposable to add, not nullNullPointerException
- if disposable
is nullpublic boolean addAll(@NonNull Disposable... disposables)
disposables
- the array of DisposablesNullPointerException
- if disposables
or any of its array items is nullpublic boolean remove(@NonNull Disposable disposable)
remove
in interface io.reactivex.rxjava3.internal.disposables.DisposableContainer
disposable
- the disposable to remove and dispose, not nullpublic boolean delete(@NonNull Disposable disposable)
delete
in interface io.reactivex.rxjava3.internal.disposables.DisposableContainer
disposable
- the disposable to remove, not nullNullPointerException
- if disposable
is nullpublic void clear()
public int size()