Hello there,
I’m wondering why I should prepend await
keyword to NotificationCenter.default.notifications(for:)
method which is introduced in Adding an asynchronous stream to NotificationCenter section. notifications(for:)
only returns AsyncStream
and it doesn’t seem to await something.
But if I omit await
keyword, the compiler complains that “Expression is ‘async’ but is not marked with ‘await’”. The error goes away if I remove async
keyword from the method observeAppStatus()
which calls notifications(for:)
method.
I really appreciate if you could explain the reason prepending await
keyword to notifications(for:)
method.
Best regards,
Henry.