public final class

CompositeDisposable

extends Object
implements Disposable DisposableContainer
java.lang.Object
   ↳ io.reactivex.disposables.CompositeDisposable

Class Overview

A disposable container that can hold onto multiple other disposables and offers O(1) add and removal complexity.

Summary

Public Constructors
CompositeDisposable()
Creates an empty CompositeDisposable.
CompositeDisposable(Disposable... resources)
Creates a CompositeDisposables with the given array of initial elements.
CompositeDisposable(Iterable<? extends Disposable> resources)
Creates a CompositeDisposables with the given Iterable sequence of initial elements.
Public Methods
boolean add(Disposable d)
boolean addAll(Disposable... ds)
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 d)
void dispose()
Dispose the resource, the operation should be idempotent.
boolean isDisposed()
Returns true if this resource has been disposed.
boolean remove(Disposable d)
int size()
Returns the number of currently held Disposables.
[Expand]
Inherited Methods
From class java.lang.Object
From interface io.reactivex.disposables.Disposable
From interface io.reactivex.internal.disposables.DisposableContainer

Public Constructors

public CompositeDisposable ()

Creates an empty CompositeDisposable.

public CompositeDisposable (Disposable... resources)

Creates a CompositeDisposables with the given array of initial elements.

Parameters
resources the array of Disposables to start with

public CompositeDisposable (Iterable<? extends Disposable> resources)

Creates a CompositeDisposables with the given Iterable sequence of initial elements.

Parameters
resources the Iterable sequence of Disposables to start with

Public Methods

public boolean add (Disposable d)

public boolean addAll (Disposable... ds)

Atomically adds the given array of Disposables to the container or disposes them all if the container has been disposed.

Parameters
ds the array of Disposables
Returns
  • true if the operation was successful, false if the container has been disposed

public void clear ()

Atomically clears the container, then disposes all the previously contained Disposables.

public boolean delete (Disposable d)

public void dispose ()

Dispose the resource, the operation should be idempotent.

public boolean isDisposed ()

Returns true if this resource has been disposed.

Returns
  • true if this resource has been disposed

public boolean remove (Disposable d)

public int size ()

Returns the number of currently held Disposables.

Returns
  • the number of currently held Disposables