Instance Method インスタンスメソッド

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: Result<Element, Failure>) -> AsyncThrowingStream<Element, Failure>.Continuation.YieldResult where Failure == Error

Parameters パラメータ

result

A result to yield from the continuation. その継続から生まれた結果。 In the .success(_:) case, this returns the associated value from the iterator’s next() method. If the result is the failure(_:) case, this call terminates the stream with the result’s error, by calling finish(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.

See Also 参照

Producing Elements