PubSub

  • An abstract base class for observable sequences.

    Subclasses must override subscribe(_:) to provide the subscription behavior. For a callback-style observable, use Observables.create and provide a SubscriptionHandler.

    Completion contract: After onComplete() is forwarded to a downstream observer, no further onNext events will be delivered through that subscription. The subscription is considered terminated and its resources are released.

    Warning

    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, use subscribeOn immediately before subscribing, to ensure subscription happens on the source’s queue.
    See more

    Declaration

    Swift

    public class Observable<Element> : Subscribable, ObservableConvertible
  • A type that can be converted to an Observable.

    See more

    Declaration

    Swift

    public protocol ObservableConvertible<Element>
  • An observable that holds the current value as the current state.

    You can use updates to receive only future updates in a new observable.

    See more

    Declaration

    Swift

    public class ObservableState<Element> : Observable<Element>
  • Contains factory methods for creating common Observable instances for use with the Tealium SDK.

    See more

    Declaration

    Swift

    public enum Observables
  • A Subject that, 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 Observable to the other classes.

    See more

    Declaration

    Swift

    @propertyWrapper
    public class ReplaySubject<Element> : Subject<Element>
  • A Subject that 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 ObservableState to the other classes.

    See more

    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 Observable to the other classes.

    See more

    Declaration

    Swift

    @propertyWrapper
    public class Subject<Element> : Subscribable, Observer, ObservableConvertible
  • A Subscribable implementation whereby only a single result is expected to be emitted to the subscriber.

    See more

    Declaration

    Swift

    public class Single<Element> : Subscribable
  • SingleResult From TealiumPrismCore

    A Single that completes with a Result<T, Error>.

    With a SingleResult you can subscribe as any other type of Single, but you can also subscribe only for onSuccess or onFailure to 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 Disposable that can hold multiple child Disposable instances for bulk disposal.

    When a CompositeDisposable is disposed, all of its children are disposed.

    See more

    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.
    • isDisposed returns true after dispose() has been called.
    • Implementations are NOT thread-safe unless specifically documented (e.g. Disposables.composite(queue:)).
    See more

    Declaration

    Swift

    public protocol Disposable : AnyObject
  • 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()
    
    See more

    Declaration

    Swift

    public enum Disposables
  • A type that can be subscribed to by an Observer to receive elements and completion.

    See more

    Declaration

    Swift

    public protocol Subscribable<Element>
  • An object from which you can extract an optional value.

    See more

    Declaration

    Swift

    public protocol ValueExtractor<ValueType>