File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
FirebaseAuth/Sources/Swift/Auth Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1361,6 +1361,23 @@ extension Auth: AuthInterop {
13611361 }
13621362 }
13631363
1364+ public struct AuthState {
1365+ let auth : Auth
1366+ let user : FirebaseAuth . User ?
1367+ }
1368+
1369+ open var authStateChanges : AsyncStream < AuthState > {
1370+ return AsyncStream { continuation in
1371+ let listener = self . addStateDidChangeListener { auth, user in
1372+ continuation. yield ( AuthState ( auth: auth, user: user) )
1373+ }
1374+
1375+ continuation. onTermination = { _ in
1376+ self . removeStateDidChangeListener ( listener)
1377+ }
1378+ }
1379+ }
1380+
13641381 /// Unregisters a block as an "auth state did change" listener.
13651382 /// - Parameter listenerHandle: The handle for the listener.
13661383 @objc ( removeAuthStateDidChangeListener: )
You can’t perform that action at this time.
0 commit comments