Skip to content

Async Handlers

Compare
Choose a tag to compare
@swhitty swhitty released this 24 May 22:34
· 66 commits to main since this release
73f0374

Adds support for async closures, making it easy to store the continuations within an actor:

let val: String? = await withIdentifiableContinuation {
  await someActor.insertContinuation($0)
} onCancel: {
  await someActor.cancelContinuation(for: $0)
}

The onCancel: handler is still guaranteed to be called after the continuation body executes to completion, even if the task is already cancelled.