Disposables
public enum Disposables
Contains factory methods for creating common Disposable instances for use with the Tealium SDK.
Disposable implementations are not Thread safe. An application that wants to dispose of multiple Tealium’s Disposables at the same time,
should only use Disposables.composite(for: tealium) instances, passing a Tealium instance as a parameter.
let sharedDisposable = Disposables.composite(for: tealium)
func subscribeToDataLayerChanges() {
tealium.dataLayer.onDataUpdated.subscribe { updated in
print("New dataLayer update: \(updated)")
}.addTo(sharedDisposable)
tealium.dataLayer.onDataRemoved.subscribe { removed in
print("Data removed for keys \(removed)")
}.addTo(sharedDisposable)
}
// Later, when changes events are no longer needed
sharedDisposable.dispose()
-
Creates a NON Thread Safe
CompositeDisposablewhich can be used to store multipleDisposableinstances for bulk disposal.Additional
Disposableinstances can be added viaCompositeDisposable.add.The returned implementation is not considered to be thread-safe, so interaction is expected to be constrained to an appropriate thread by the user.
Declaration
Swift
static func composite() -> any CompositeDisposableReturn Value
A
CompositeDisposableto dispose of multipleDisposableat once. -
Creates a NON Thread Safe
Disposablewhich calls the givenonDisposeblock when disposed.The returned implementation is not considered to be thread-safe, so interaction is expected to be constrained to an appropriate thread by the user.
Declaration
Swift
static func subscription(onDispose: @escaping () -> Void) -> any DisposableParameters
onDisposeCallback to execute when this
Disposableis disposed.Return Value
A
Disposablethat calls theonDisposeblock upon disposal. -
Creates a
CompositeDisposablewhich can be used to store multipleDisposableinstances for bulk disposal. All methods are executed using the givenqueueto ensure operation is thread-safe.Additional
Disposableinstances can be added viaCompositeDisposable.add.Declaration
Swift
static func composite(queue: TealiumQueue) -> any CompositeDisposableParameters
queueThe
TealiumQueueinstance to use for all operations of thisCompositeDisposable. Must be the same one used from the operations that can be disposed by thisCompositeDisposable.Return Value
A
CompositeDisposableto dispose some operations, whilst ensuring that all operations happen on the givenqueue. -
Creates a
CompositeDisposablewhich can be used to store multipleDisposableinstances for bulk disposal. All methods are executed using the internalTealiumqueue to ensure operation is thread-safe when containingTealiumreturned subscriptions.Additional
Disposableinstances can be added viaCompositeDisposable.add.Declaration
Swift
static func composite(for tealium: Tealium) -> any CompositeDisposableReturn Value
A
CompositeDisposableto dispose some operations, whilst ensuring that all operations happen on theTealiuminternal queue. -
Creates a NON Thread Safe
CompositeDisposablewhich can be used to store multipleDisposableinstances for bulk disposal. ThisCompositeDisposablewill automatically dispose upon deinitialization.Additional
Disposableinstances can be added viaCompositeDisposable.add.The returned implementation is not considered to be thread-safe, so interaction is expected to be constrained to an appropriate thread by the user.
Declaration
Swift
static func automatic() -> any CompositeDisposableReturn Value
A
CompositeDisposableto dispose of multipleDisposableat once. -
Returns a
Disposableimplementation that:- always returns
trueforDisposable.isDisposed does nothing for
Disposable.dispose
Declaration
Swift
static func disposed() -> any Disposable - always returns
View on GitHub