CompositeDisposable
public final class CompositeDisposable: Disposable
A disposable that will dispose of any number of other disposables.
-
Represents a handle to a disposable previously added to a
See moreCompositeDisposable
.Declaration
Swift
public final class DisposableHandle
-
Remove the pointed-to disposable from its
CompositeDisposable
.Note
This is useful to minimize memory growth, by removing disposables that are no longer needed.Declaration
Swift
public var isDisposed: Bool
-
Initialize a
CompositeDisposable
containing the given sequence of disposables.Declaration
Swift
public init<S: Sequence>(_ disposables: S) where S.Iterator.Element == Disposable
Parameters
disposables
A collection of objects conforming to the
Disposable
protocol -
Initialize a
CompositeDisposable
containing the given sequence of disposables.Declaration
Swift
public convenience init<S: Sequence>(_ disposables: S) where S.Iterator.Element == Disposable?
Parameters
disposables
A collection of objects conforming to the
Disposable
protocol -
Initializes an empty
CompositeDisposable
.Declaration
Swift
public convenience init()
-
Initializes an empty
CompositeDisposable
.Declaration
Swift
public func dispose()
-
Add the given disposable to the list, then return a handle which can be used to opaquely remove the disposable later (if desired).
Declaration
Swift
public func add(_ d: Disposable?) -> DisposableHandle
Parameters
d
Optional disposable.
Return Value
An instance of
DisposableHandle
that can be used to opaquely remove the disposable later (if desired). -
Add an ActionDisposable to the list.
Declaration
Swift
public func add(_ action: @escaping () -> Void) -> DisposableHandle
Parameters
action
A closure that will be invoked when
dispose()
is called.Return Value
An instance of
DisposableHandle
that can be used to opaquely remove the disposable later (if desired).