/** * {@inheritdoc} */ public function dispose(Throwable $exception = null) { if (null === $exception) { $exception = new DisposedException(); } $this->emitter = null; if (null === $this->coroutine) { $this->queue->fail($exception); return; } if (null !== $this->onDisposed) { try { $result = ($this->onDisposed)($exception); if ($result instanceof Generator) { $awaitable = new Coroutine($result); } else { $awaitable = resolve($result); } $awaitable = $awaitable->then(function () use($exception) { throw $exception; }); } catch (Throwable $exception) { $awaitable = reject($exception); } } else { $awaitable = reject($exception); } $awaitable->done(null, [$this->coroutine, 'cancel']); }
/** * {@inheritdoc} */ public function dispose(Throwable $exception = null) { if (null === $exception) { $exception = new DisposedException('Observable disposed.'); } $this->emitter = null; $this->queue->fail($exception); if (null !== $this->coroutine) { $this->coroutine->cancel($exception); } }