PubSub
-
An abstract base class for observable sequences.
Subclasses must override
subscribe(_:)to provide the subscription behavior. For a callback-style observable, useObservables.createand provide aSubscriptionHandler.Completion contract: After
onComplete()is forwarded to a downstream observer, no furtheronNextevents will be delivered through that subscription. The subscription is considered terminated and its resources are released.See moreWarning
This class is not generically Thread safe. Usage, including operators, subscription and emission of events, must be done from a single queue. When the source emits on a different queue than the caller, usesubscribeOnimmediately before subscribing, to ensure subscription happens on the source’s queue.Declaration
Swift
public class Observable<Element> : Subscribable, ObservableConvertible -
A type that can be converted to an
See moreObservable.Declaration
Swift
public protocol ObservableConvertible<Element> -
An observable that holds the current value as the current state.
You can use
See moreupdatesto receive only future updates in a new observable.Declaration
Swift
public class ObservableState<Element> : Observable<Element> -
Contains factory methods for creating common
See moreObservableinstances for use with the Tealium SDK.Declaration
Swift
public enum Observables -
A
Subjectthat, in addition to normal emission and subscribe behavior, holds a cache of items and sends it, in order, to each new observer that is subscribed.You can use it as a property wrapper to make the emitting private in the class where it’s contained, but still expose an
See moreObservableto the other classes.Declaration
Swift
@propertyWrapper public class ReplaySubject<Element> : Subject<Element> -
A
Subjectthat must always have a value.You can use it as a property wrapper to make the emitting private in the class where it’s contained, but still expose an
See moreObservableStateto the other classes.Declaration
Swift
@propertyWrapper public class StateSubject<Element> : Subject<Element> -
A subscribable source that can emit events to its observers and be an observer itself.
You can use it as a property wrapper to make the emission private in the class where it’s contained, but still expose an
See moreObservableto the other classes.Declaration
Swift
@propertyWrapper public class Subject<Element> : Subscribable, Observer, ObservableConvertible -
A
See moreSubscribableimplementation whereby only a single result is expected to be emitted to the subscriber.Declaration
Swift
public class Single<Element> : Subscribable -
SingleResultFrom TealiumPrismCoreA
Singlethat completes with aResult<T, Error>.With a
SingleResultyou cansubscribeas any other type ofSingle, but you can also subscribe only foronSuccessoronFailureto receive the event only in case the event is respectively either a success or a failure.So in case you want to handle both success and failure:
single.subscribe { result in switch result { case let .success(output): // Handle success break case let .failure(error): // Handle failure break }In case you want to handle only successes:
single.onSuccess { output in // Handle success }In case you want to handle only failures:
single.onFailure { error in // Handle failure }Declaration
Swift
public typealias SingleResult<T, E> = Single<Result<T, E>> where E : Error -
A
Disposablethat can hold multiple childDisposableinstances for bulk disposal.When a
See moreCompositeDisposableis disposed, all of its children are disposed.Declaration
Swift
public protocol CompositeDisposable : Disposable -
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:)).
Declaration
Swift
public protocol Disposable : AnyObject -
Contains factory methods for creating common
Disposableinstances 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 useDisposables.composite(for: tealium)instances, passing aTealiuminstance as a parameter.
See morelet 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()Declaration
Swift
public enum Disposables -
An object from which you can extract an optional value.
See moreDeclaration
Swift
public protocol ValueExtractor<ValueType>
View on GitHub
PubSub Reference