BaseNotificationMonitor

open class BaseNotificationMonitor: BaseMonitor

An abstract base class that simplifies the implementation of a monitor which relies on one or more notification observers.

  • Adds observers to the default notification center.

    If monitoring is already active when the startMonitoring() method is invoked, this method is not called. If you override this method, you must be sure to invoke the superclass implementation.

    Declaration

    Swift

    open func addNotificationObservers()
  • Removes observers from the default notification center.

    If monitoring is not active when the stopMonitoring() method is invoked, this method is not called. The default implementation of this method removes all observers from the specified notification center. If you override this method, you must be sure to invoke the superclass implementation.

    Declaration

    Swift

    open func removeNotificationObservers()
  • Initializes a new base notification monitor.

    Declaration

    Swift

    public init(queue: OperationQueue)

    Parameters

    queue

    The operation queue on which notification blocks execute.

  • Adds an observer to the default notification center

    Declaration

    Swift

    public func observe(_ name: Notification.Name,
                        object: Any? = nil,
                        using block: @escaping (Notification) -> Void)

    Parameters

    name

    The name of the notification for which to register the observer; that is, only notifications with this name are used to add the block to the operation queue.

    object

    The object whose notifications the observer wants to receive; that is, only notifications sent by this sender are used to add the block to the operation queue.

    block

    The block to be executed when the notification is received.

  • Declaration

    Swift

    public override final func cleanupMonitor()
  • Declaration

    Swift

    public override final func configureMonitor()