From eb49e6e8ffdafc01b1a0d2989931b0cad38b684f Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Tue, 31 May 2016 15:01:07 -0500 Subject: [PATCH] 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 --- lib/Internal/Producer.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Internal/Producer.php b/lib/Internal/Producer.php index 8e794a5..b6eb382 100644 --- a/lib/Internal/Producer.php +++ b/lib/Internal/Producer.php @@ -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) {