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

Initialization

AsyncSequence

  • 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.

Iterator

  • Declaration

    Swift

    public struct Iterator : AsyncIteratorProtocol