Observable

public protocol Observable

Observable is an interface for a container of observers. It allows sending notifications on certain events to all of the registered 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 will apply the notificationAction closure to every registered 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 will apply the notificationAction closure to every registered observer.

    completion

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

  • Register an Observer in the Observable container.

    Declaration

    Swift

    func addObserver(_ observer: Observer)

    Parameters

    observer

    Observer to register.

  • Unregister an Observer.

    Declaration

    Swift

    func removeObserver(_ observer: Observer)

    Parameters

    observer

    Observer to unregister.