NotificationCenterAsyncSequence
public struct NotificationCenterAsyncSequence : AsyncSequence
An async sequence that emits when a notification center broadcasts notifications.
let sequence = NotificationCenterAsyncSequence(
notificationCenter: .default,
notificationName: UIDevice.orientationDidChangeNotification,
object: nil
)
for await element in sequence {
print(element)
}
-
The kind of elements streamed.
Declaration
Swift
public typealias Element = Notification
-
Declaration
Swift
public init( notificationCenter: NotificationCenter, notificationName: Notification.Name, object: AnyObject? = nil )
-
Creates an async iterator that emits elements of this async sequence.
Declaration
Swift
public func makeAsyncIterator() -> Iterator
Return Value
An instance that conforms to
AsyncIteratorProtocol
.