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:
parent
84c2572e0a
commit
2317a3aa37
@ -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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user