Created
August 12, 2023 23:18
-
-
Save mdb1/623b7bc22ae2136dcdfae8ba56e39bc2 to your computer and use it in GitHub Desktop.
Notification Center Publisher protocol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Reflects notification publisher functionality of `NotificationCenter`. | |
public protocol NotificationPublisherProtocol: AnyObject { | |
/// Returns a publisher that emits events when broadcasting notifications. | |
/// - Parameters: | |
/// - name: The name of the notification to publish. | |
/// - object: The object posting the named notification. If `nil`, the publisher emits elements for any object | |
/// producing a notification with the given name. | |
/// - Returns: A publisher that emits events when broadcasting notifications. | |
func publisher(for name: Notification.Name, object: AnyObject?) -> NotificationCenter.Publisher | |
} | |
public extension NotificationPublisherProtocol { | |
/// Returns a publisher that emits events when broadcasting notifications. | |
/// - Parameters: | |
/// - name: The name of the notification to publish. | |
/// - Returns: A publisher that emits events when broadcasting notifications. | |
func publisher(for name: Notification.Name) -> NotificationCenter.Publisher { | |
publisher(for: name, object: nil) | |
} | |
} | |
extension NotificationCenter: NotificationPublisherProtocol {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment