TypedNotificationCenter
public protocol TypedNotificationCenter
A type that can post TypedNotifications and add notification observers.
-
Posts a
TypedNotificationDeclaration
Swift
func post<T>(_ notification: T) where T : TypedNotificationParameters
notificationThe notification to post.
-
Registers a block to be executed when a matching notification is posted.
Declaration
Swift
func addObserver<T>(forType type: T.Type, object obj: T.Object?, queue: OperationQueue?, using block: @escaping (T) -> Void) -> NotificationObservation where T : TypedNotificationParameters
typeThe type of notification to observe.
objectAn object to filter notifications by. Only notifications whose object is
objectwill be delivered to the observer. Passnilto receive notifications from all objects.queueAn OperationQueue to run
blockon. Passnilto haveblockevaluated synchronously on the posting thread.blockA block to execute when a matching notification is posted. The block takes the matching notification as an argument.
Return Value
A notification observation that manages the lifetime of the observer. When the observation is deallocated, the notification observer is removed.
View on GitHub
TypedNotificationCenter Protocol Reference