You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,16 @@ let val: String? = await withIdentifiableContinuation { continuation in
42
42
}
43
43
```
44
44
45
+
`async` closures can be used making it easy to store the continuations within an actor:
46
+
47
+
```swift
48
+
let val: String?=awaitwithIdentifiableContinuation {
49
+
await actor.insertContinuation($0)
50
+
} onCancel: {
51
+
await actor.cancelContinuation(for: $0)
52
+
}
53
+
```
54
+
45
55
> Note: The `onCancel:` handler is guaranteed to be called after the continuation body even if the task is already cancelled. Manually check `Task.isCancelled` before creating the continuation to prevent performing unrequired work.
0 commit comments