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

Drop special behavior when emitting an observable

This commit is contained in:
Aaron Piotrowski 2016-08-23 13:17:59 -05:00
parent 3ce0c0dd37
commit 6e1c1db5a6

View File

@ -48,30 +48,17 @@ trait Producer {
}
if ($value instanceof Awaitable) {
if ($value instanceof Observable) {
$value->subscribe(function ($value) {
if ($this->resolved) {
return null;
}
return $this->emit($value);
});
$value->when(function ($e) {
if ($e && !$this->resolved) {
$this->fail($e);
}
});
return $value; // Do not emit observable result.
}
$deferred = new Deferred;
$value->when(function ($e, $v) use ($deferred) {
if ($this->resolved) {
$deferred->fail(
new \Error("The observable was resolved before the awaitable result could be emitted")
);
return;
}
if ($e) {
if (!$this->resolved) {
$this->fail($e);
}
$this->fail($e);
$deferred->fail($e);
return;
}