Documentation

Event

Namespaces

Loop
Promise

Interfaces, Classes and Traits

EmitterInterface
Event Emitter Interface.
Emitter
Emitter object.
EventEmitter
This is the old name for the Emitter class.
Promise
An implementation of the Promise pattern.
PromiseAlreadyResolvedException
This exception is thrown when the user tried to reject or fulfill a promise, after either of these actions were already performed.
Version
This class contains the version number for this package.
WildcardEmitter
This class is an EventEmitter with support for wildcard event handlers.
EmitterTrait
Event Emitter Trait.
WildcardEmitterTrait
Wildcard Emitter Trait.

Table of Contents

coroutine()  : Promise
Turn asynchronous promise-based code into something that looks synchronous again, through the use of generators.

Functions

coroutine()

Turn asynchronous promise-based code into something that looks synchronous again, through the use of generators.

coroutine(callable $gen) : Promise

Example without coroutines:

$promise = $httpClient->request('GET', '/foo'); $promise->then(function($value) {

return $httpClient->request('DELETE','/foo');

})->then(function($value) {

return $httpClient->request('PUT', '/foo');

})->error(function($reason) {

echo "Failed because: $reason\n";

});

Example with coroutines:

coroutine(function() {

try { yield $httpClient->request('GET', '/foo'); yield $httpClient->request('DELETE', /foo'); yield $httpClient->request('PUT', '/foo'); } catch(\Throwable $reason) { echo "Failed because: $reason\n"; }

});

Parameters
$gen : callable
Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Return values
Promise

Search results