Skip to content

Commit 1907121

Browse files
committed
Update README
1 parent e058e99 commit 1907121

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ let val: String? = await withIdentifiableContinuation { continuation in
4242
}
4343
```
4444

45+
`async` closures can be used making it easy to store the continuations within an actor:
46+
47+
```swift
48+
let val: String? = await withIdentifiableContinuation {
49+
await actor.insertContinuation($0)
50+
} onCancel: {
51+
await actor.cancelContinuation(for: $0)
52+
}
53+
```
54+
4555
> 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.
4656
4757
## Checked/UnsafeContinuation

0 commit comments

Comments
 (0)