enum AsyncStream.Continuation.Termination
A type that indicates how the stream terminated.
Availability
Technology
var onTermination: (@Sendable (AsyncStream
<Element>.Continuation
.Termination
) -> Void
)? { get nonmutating set }
If an on
callback is set, using task cancellation to terminate iteration of an Async
results in a call to this callback.
Canceling an active iteration invokes the on
callback first, then resumes by yielding nil
. This means that you can perform needed cleanup in the cancellation handler. After reaching a terminal state as a result of cancellation, the Async
sets the callback to nil
.
enum AsyncStream.Continuation.Termination