Skip to content

Commit 01f18f2

Browse files
committed
Add comments explaining nested task
1 parent 319ebc2 commit 01f18f2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

FirebaseAI/Sources/Types/Internal/Live/LiveSessionService.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ actor LiveSessionService {
115115
/// resuming the same session.
116116
func connect() {
117117
setupTask.cancel()
118+
// we launch the setup task in a seperate task to avoid blocking the parent context
118119
setupTask = Task { [weak self] in
120+
// we need a continuation to surface that the setup is complete, while still allowing us to listen to the server
119121
try await withCheckedThrowingContinuation { setupContinuation in
122+
// nested task so we can use await
120123
Task { [weak self] in
121124
guard let self else { return }
122125
await self.listenToServer(setupContinuation)

0 commit comments

Comments
 (0)