TypedNotificationCenter
public protocol TypedNotificationCenter
A type that can post TypedNotification
s and add notification observers.
-
Posts a
TypedNotification
Declaration
Swift
func post<T>(_ notification: T) where T : TypedNotification
Parameters
notification
The 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 : TypedNotification
Parameters
type
The type of notification to observe.
object
An object to filter notifications by. Only notifications whose object is
object
will be delivered to the observer. Passnil
to receive notifications from all objects.queue
An OperationQueue to run
block
on. Passnil
to haveblock
evaluated synchronously on the posting thread.block
A 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.