yield(with:)
Resume the task awaiting the next iteration point by having it return normally or throw, based on a given result.
Declaration
@discardableResult func yield(with result: sending Result<Element, Failure>) -> AsyncThrowingStream<Element, Failure>.Continuation.YieldResult where Failure == any ErrorParameters
- result:
A result to yield from the continuation. In the
.success(_:)case, this returns the associated value from the iterator’snext()method. If the result is thefailure(_:)case, this call terminates the stream with the result’s error, by callingfinish(throwing:).
Return Value
A YieldResult that indicates the success or failure of the yield operation.
Discussion
If nothing is awaiting the next value and the result is success, this call attempts to buffer the result’s element.
If you call this method repeatedly, each call returns immediately, without blocking for any awaiting consumption from the iteration.