Amp\Coroutine classCoroutine implementsAmp\Promise

Creates a promise from a generator function yielding promises.

When a promise is yielded, execution of the generator is interrupted until the promise is resolved. A success value is sent into the generator, while a failure reason is thrown into the generator. Using a coroutine, asynchronous code can be written without callbacks and be structured like synchronous code.

Summary

Properties

Methods

Properties

Methods

__construct —public function__construct(Generator$generator)
No documentation.
Type Parameter Description Default Value
Generator $generator No documentation. none
onResolve —public functiononResolve(callable$onResolved)
No documentation.
Type Parameter Description Default Value
callable $onResolved No documentation. none