1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Unsubscribe from emitted observable if failed

This commit is contained in:
Aaron Piotrowski 2016-08-16 16:31:09 -05:00
parent 84c2572e0a
commit 2317a3aa37

View File

@ -81,7 +81,13 @@ trait Producer {
if ($value instanceof Awaitable) { if ($value instanceof Awaitable) {
if ($value instanceof Observable) { if ($value instanceof Observable) {
$value->subscribe(function ($value) { $subscriber = $value->subscribe(function ($value) use (&$subscriber) {
/** @var \Amp\Subscriber $subscriber */
if ($this->resolved) {
$subscriber->unsubscribe();
return;
}
return $this->emit($value); return $this->emit($value);
}); });