Observable

public protocol Observable

Observable is an interface for a container of observers. It allows sending notifications on certain events to all of the added observers.

We provide the implementation of this protocol: TomTomSDKCommon/ObservableHandler.

  • Notify observers about some specific event.

    Declaration

    Swift

    func notifyObservers(notificationAction: @escaping (Observer) -> ())

    Parameters

    notificationAction

    Use the closure to define what event every observer will receive. This method applies the notificationAction closure to every added observer.

  • Notify observers about some specific event.

    Declaration

    Swift

    func notifyObservers(notificationAction: @escaping (Observer) -> (), completion: (() -> ())?)

    Parameters

    notificationAction

    Use the closure to define what event every observer will receive. This method applies the notificationAction closure to every added observer.

    completion

    Called when the notificationAction closure is applied to all the added observers.

  • Add an Observer in the Observable container.

    Declaration

    Swift

    func addObserver(_ observer: Observer)

    Parameters

    observer

    Observer to add.

  • Remove an Observer.

    Declaration

    Swift

    func removeObserver(_ observer: Observer)

    Parameters

    observer

    Observer to remove.