Disposable
public protocol Disposable : AnyObject
A protocol representing a subscription or long-lived operation that can be cancelled.
Contract:
dispose()is idempotent — calling it multiple times is safe and has no additional effect.isDisposedreturnstrueafterdispose()has been called.- Implementations are NOT thread-safe unless specifically documented (e.g.
Disposables.composite(queue:)).
-
Whether this disposable has been disposed.
Declaration
Swift
var isDisposed: Bool { get } -
Disposes of this resource. Must be idempotent (safe to call multiple times) in conforming types.
Declaration
Swift
func dispose() -
addTo(_:Extension method) Add the disposable to a group so that it can be disposed along the others.
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 addTo(_ container: any CompositeDisposable) -> SelfParameters
containerThe
CompositeDisposablegroup that will contain the disposable.Return Value
Self after adding it to the container, to allow chaining.
View on GitHub