Initial Release
IdentifiableContinuation is a lightweight wrapper around CheckedContinuation and UnsafeContinuation that conforms to Identifiable and including an easy to use cancellation handler with the id.
Usage is similar to existing continuations:
let val: String = await withIdentifiableContinuation {
$0.resume(returning: "bar")
}The continuation includes an id that can be attached to an asynchronous task enabling the onCancel handler to cancel it.
let val: String? = await withIdentifiableContinuation { continuation in
foo.startTask(for: continuation.id) { result
continuation.resume(returning: result)
}
} onCancel: { id in
foo.cancelTask(for: id)
}