1
0
mirror of https://github.com/danog/amp.git synced 2024-11-26 20:15:00 +01:00

Resolve emit with observable result instead of emitting

Emitting another observable will emit values from the emitted observable, then resolve the awaitable returned from emit with the observable result
This commit is contained in:
Aaron Piotrowski 2016-05-31 15:01:07 -05:00
parent a52e1e4c33
commit eb49e6e8ff

View File

@ -106,13 +106,16 @@ trait Producer {
*/
private function push($value) {
try {
if ($value instanceof Awaitable) {
$value = (yield $value);
} elseif ($value instanceof Observable) {
if ($value instanceof Observable) {
$disposable = $value->subscribe(function ($value) {
return $this->emit($value);
});
$value = (yield $disposable);
yield Coroutine::result(yield $disposable);
return;
}
if ($value instanceof Awaitable) {
$value = (yield $value);
}
} catch (\Throwable $exception) {
if (!$this->resolved) {