14
14
15
15
import Foundation
16
16
17
- #if swift(>=5.5.2)
18
- @available ( iOS 13 . 0 , macOS 10 . 15 , macCatalyst 13 . 0 , tvOS 13 . 0 , watchOS 7 . 0 , * )
19
- public extension Auth {
20
- /// An asynchronous stream of authentication state changes.
17
+ public extension Auth {
18
+ /// An asynchronous sequence of authentication state changes.
21
19
///
22
- /// This stream provides a modern, `async/await`-compatible way to monitor the authentication
20
+ /// This sequence provides a modern, `async/await`-compatible way to monitor the authentication
23
21
/// state of the current user. It emits a new `User?` value whenever the user signs in or
24
22
/// out.
25
23
///
26
- /// The stream 's underlying listener is automatically managed. It is added to the `Auth`
27
- /// instance when you begin iterating over the stream and is removed when the iteration
24
+ /// The sequence 's underlying listener is automatically managed. It is added to the `Auth`
25
+ /// instance when you begin iterating over the sequence and is removed when the iteration
28
26
/// is cancelled or terminates.
29
27
///
30
- /// - Important: The first value emitted by this stream is always the *current* authentication
28
+ /// - Important: The first value emitted by this sequence is always the *current* authentication
31
29
/// state, which may be `nil` if no user is signed in.
32
30
///
33
31
/// ### Example Usage
@@ -47,7 +45,8 @@ import Foundation
47
45
/// }
48
46
/// }
49
47
/// ```
50
- var authStateChanges : AsyncStream < User ? > {
48
+ @available ( iOS 18 . 0 , * )
49
+ var authStateChanges : some AsyncSequence < User ? , Never > {
51
50
AsyncStream { continuation in
52
51
let listenerHandle = addStateDidChangeListener { _, user in
53
52
continuation. yield ( user)
@@ -59,16 +58,16 @@ import Foundation
59
58
}
60
59
}
61
60
62
- /// An asynchronous stream of ID token changes.
61
+ /// An asynchronous sequence of ID token changes.
63
62
///
64
- /// This stream provides a modern, `async/await`-compatible way to monitor changes to the
63
+ /// This sequence provides a modern, `async/await`-compatible way to monitor changes to the
65
64
/// current user's ID token. It emits a new `User?` value whenever the ID token changes.
66
65
///
67
- /// The stream 's underlying listener is automatically managed. It is added to the `Auth`
68
- /// instance when you begin iterating over the stream and is removed when the iteration
66
+ /// The sequence 's underlying listener is automatically managed. It is added to the `Auth`
67
+ /// instance when you begin iterating over the sequence and is removed when the iteration
69
68
/// is cancelled or terminates.
70
69
///
71
- /// - Important: The first value emitted by this stream is always the *current* authentication
70
+ /// - Important: The first value emitted by this sequence is always the *current* authentication
72
71
/// state, which may be `nil` if no user is signed in.
73
72
///
74
73
/// ### Example Usage
@@ -88,16 +87,16 @@ import Foundation
88
87
/// }
89
88
/// }
90
89
/// ```
91
- var idTokenChanges : AsyncStream < User ? > {
90
+ @available ( iOS 18 . 0 , * )
91
+ var idTokenChanges : some AsyncSequence < User ? , Never > {
92
92
AsyncStream { continuation in
93
93
let listenerHandle = addIDTokenDidChangeListener { _, user in
94
94
continuation. yield ( user)
95
95
}
96
96
97
97
continuation. onTermination = { @Sendable _ in
98
- self . removeStateDidChangeListener ( listenerHandle)
98
+ self . removeIDTokenDidChangeListener ( listenerHandle)
99
99
}
100
100
}
101
101
}
102
102
}
103
- #endif // swift(>=5.5.2)
0 commit comments