/** * @return array An array in the form of [Amp\Reactor, Amp\Artax\AsyncClient] */ public function build() { $reactor = reactor(); return array($reactor, new Client($reactor)); }
/** * Resolve a Generator coroutine function * * Upon resolution the Generator return value is used to succeed the promised result. If an * error occurs during coroutine resolution the returned promise fails. * * @param \Generator $generator The generator to resolve as a coroutine */ function resolve(\Generator $generator) { $cs = new CoroutineState(); $cs->promisor = new Deferred(); $cs->generator = $generator; $cs->returnValue = null; $cs->currentPromise = null; $cs->nestingLevel = 0; $cs->reactor = reactor(); __coroutineAdvance($cs); return $cs->promisor->promise(); }