CompositeDisposable
public protocol CompositeDisposable : Disposable
A Disposable that can hold multiple child Disposable instances for bulk disposal.
When a CompositeDisposable is disposed, all of its children are disposed.
-
Adds a
Disposableto this composite.If this composite is already disposed, the added disposable is immediately disposed. If the disposable is already disposed, it is not added.
Warning
Make sure both disposables work from the same queue. For
TealiumcreatedSubscribables, they will always work from theTealiumQueue.worker. If you want to add another disposable to a TealiumDisposable, or add it to another disposable, make sure you create it like this:Disposables.composite(for: tealium), passing the relativeTealiuminstance.Declaration
Swift
@discardableResult func add(_ disposable: any Disposable) -> SelfParameters
disposableThe disposable to add.
Return Value
Self after adding the new disposable, to allow chaining.
-
Removes a disposable from this composite using reference identity (
===). The removed disposable is NOT disposed — it is only detached from this container.Declaration
Swift
func remove(_ disposable: any Disposable)Parameters
disposableThe disposable to remove.
-
onDispose(_:Extension method) Adds a block that is called upon disposal of this CompositeDisposable.
Effectively, this just adds a Subscription to this CompositeDisposable.
Warning
Make sure both disposables work from the same queue. For
TealiumcreatedSubscribables, they will always work from theTealiumQueue.worker. If you want to add another disposable to a TealiumDisposable, or add it to another disposable, make sure you create it like this:Disposables.composite(for: tealium), passing the relativeTealiuminstance.Declaration
Swift
@discardableResult func onDispose(_ block: @escaping () -> Void) -> SelfParameters
blockThe block to be called upon disposal.
Return Value
Self after adding the new disposable, to allow chaining.
View on GitHub