You are here

function __next_coroutine in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/promises/src/functions.php \GuzzleHttp\Promise\__next_coroutine()

@internal

File

vendor/guzzlehttp/promises/src/functions.php, line 480

Namespace

GuzzleHttp\Promise

Code

function __next_coroutine($yielded, \Generator $generator) {
  return promise_for($yielded)
    ->then(function ($value) use ($generator) {
    $nextYield = $generator
      ->send($value);
    return $generator
      ->valid() ? __next_coroutine($nextYield, $generator) : $value;
  }, function ($reason) use ($generator) {
    $nextYield = $generator
      ->throw(exception_for($reason));

    // The throw was caught, so keep iterating on the coroutine
    return __next_coroutine($nextYield, $generator);
  });
}