Skip to content

Commit 60c2432

Browse files
committed
Fix formatting
1 parent 3fe6416 commit 60c2432

File tree

1 file changed

+73
-73
lines changed

1 file changed

+73
-73
lines changed

FirebaseAuth/Sources/Swift/Auth/Auth+Async.swift

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,88 +15,88 @@
1515
import Foundation
1616

1717
public extension Auth {
18-
/// An asynchronous sequence of authentication state changes.
19-
///
20-
/// This sequence provides a modern, `async/await`-compatible way to monitor the authentication
21-
/// state of the current user. It emits a new `User?` value whenever the user signs in or
22-
/// out.
23-
///
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
26-
/// is cancelled or terminates.
27-
///
28-
/// - Important: The first value emitted by this sequence is always the *current* authentication
29-
/// state, which may be `nil` if no user is signed in.
30-
///
31-
/// ### Example Usage
32-
///
33-
/// You can use a `for await` loop to handle authentication changes:
34-
///
35-
/// ```swift
36-
/// func monitorAuthState() async {
37-
/// for await user in Auth.auth().authStateChanges {
38-
/// if let user = user {
39-
/// print("User signed in: \(user.uid)")
40-
/// // Update UI or perform actions for a signed-in user.
41-
/// } else {
42-
/// print("User signed out.")
43-
/// // Update UI or perform actions for a signed-out state.
44-
/// }
45-
/// }
46-
/// }
47-
/// ```
18+
/// An asynchronous sequence of authentication state changes.
19+
///
20+
/// This sequence provides a modern, `async/await`-compatible way to monitor the authentication
21+
/// state of the current user. It emits a new `User?` value whenever the user signs in or
22+
/// out.
23+
///
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
26+
/// is cancelled or terminates.
27+
///
28+
/// - Important: The first value emitted by this sequence is always the *current* authentication
29+
/// state, which may be `nil` if no user is signed in.
30+
///
31+
/// ### Example Usage
32+
///
33+
/// You can use a `for await` loop to handle authentication changes:
34+
///
35+
/// ```swift
36+
/// func monitorAuthState() async {
37+
/// for await user in Auth.auth().authStateChanges {
38+
/// if let user = user {
39+
/// print("User signed in: \(user.uid)")
40+
/// // Update UI or perform actions for a signed-in user.
41+
/// } else {
42+
/// print("User signed out.")
43+
/// // Update UI or perform actions for a signed-out state.
44+
/// }
45+
/// }
46+
/// }
47+
/// ```
4848
@available(iOS 18.0, *)
4949
var authStateChanges: some AsyncSequence<User?, Never> {
50-
AsyncStream { continuation in
51-
let listenerHandle = addStateDidChangeListener { _, user in
52-
continuation.yield(user)
53-
}
50+
AsyncStream { continuation in
51+
let listenerHandle = addStateDidChangeListener { _, user in
52+
continuation.yield(user)
53+
}
5454

55-
continuation.onTermination = { @Sendable _ in
56-
self.removeStateDidChangeListener(listenerHandle)
57-
}
55+
continuation.onTermination = { @Sendable _ in
56+
self.removeStateDidChangeListener(listenerHandle)
5857
}
5958
}
59+
}
6060

61-
/// An asynchronous sequence of ID token changes.
62-
///
63-
/// This sequence provides a modern, `async/await`-compatible way to monitor changes to the
64-
/// current user's ID token. It emits a new `User?` value whenever the ID token changes.
65-
///
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
68-
/// is cancelled or terminates.
69-
///
70-
/// - Important: The first value emitted by this sequence is always the *current* authentication
71-
/// state, which may be `nil` if no user is signed in.
72-
///
73-
/// ### Example Usage
74-
///
75-
/// You can use a `for await` loop to handle ID token changes:
76-
///
77-
/// ```swift
78-
/// func monitorIDTokenChanges() async {
79-
/// for await user in Auth.auth().idTokenChanges {
80-
/// if let user = user {
81-
/// print("ID token changed for user: \(user.uid)")
82-
/// // Update UI or perform actions for a signed-in user.
83-
/// } else {
84-
/// print("User signed out.")
85-
/// // Update UI or perform actions for a signed-out state.
86-
/// }
87-
/// }
88-
/// }
89-
/// ```
61+
/// An asynchronous sequence of ID token changes.
62+
///
63+
/// This sequence provides a modern, `async/await`-compatible way to monitor changes to the
64+
/// current user's ID token. It emits a new `User?` value whenever the ID token changes.
65+
///
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
68+
/// is cancelled or terminates.
69+
///
70+
/// - Important: The first value emitted by this sequence is always the *current* authentication
71+
/// state, which may be `nil` if no user is signed in.
72+
///
73+
/// ### Example Usage
74+
///
75+
/// You can use a `for await` loop to handle ID token changes:
76+
///
77+
/// ```swift
78+
/// func monitorIDTokenChanges() async {
79+
/// for await user in Auth.auth().idTokenChanges {
80+
/// if let user = user {
81+
/// print("ID token changed for user: \(user.uid)")
82+
/// // Update UI or perform actions for a signed-in user.
83+
/// } else {
84+
/// print("User signed out.")
85+
/// // Update UI or perform actions for a signed-out state.
86+
/// }
87+
/// }
88+
/// }
89+
/// ```
9090
@available(iOS 18.0, *)
9191
var idTokenChanges: some AsyncSequence<User?, Never> {
92-
AsyncStream { continuation in
93-
let listenerHandle = addIDTokenDidChangeListener { _, user in
94-
continuation.yield(user)
95-
}
92+
AsyncStream { continuation in
93+
let listenerHandle = addIDTokenDidChangeListener { _, user in
94+
continuation.yield(user)
95+
}
9696

97-
continuation.onTermination = { @Sendable _ in
98-
self.removeIDTokenDidChangeListener(listenerHandle)
99-
}
97+
continuation.onTermination = { @Sendable _ in
98+
self.removeIDTokenDidChangeListener(listenerHandle)
10099
}
101100
}
102101
}
102+
}

0 commit comments

Comments
 (0)