mirror of
https://github.com/danog/amp.git
synced 2025-01-22 13:21:16 +01:00
Add StreamSource::isDisposed()
This commit is contained in:
parent
3fb87e2c18
commit
ee76c97c51
@ -226,6 +226,14 @@ final class EmitSource
|
||||
return $this->completed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool True if the stream was disposed.
|
||||
*/
|
||||
public function isDisposed(): bool
|
||||
{
|
||||
return $this->disposed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes the stream.
|
||||
**
|
||||
|
@ -56,6 +56,14 @@ final class StreamSource
|
||||
return $this->source->isComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool True if the stream has been disposed.
|
||||
*/
|
||||
public function isDisposed(): bool
|
||||
{
|
||||
return $this->source->isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes the stream.
|
||||
*
|
||||
|
@ -213,6 +213,7 @@ class StreamSourceTest extends AsyncTestCase
|
||||
$stream = $this->source->stream();
|
||||
$promise = $this->source->emit(1);
|
||||
$stream->dispose();
|
||||
$this->assertTrue($this->source->isDisposed());
|
||||
$this->assertNull(yield $promise);
|
||||
yield $this->source->emit(1);
|
||||
}
|
||||
@ -226,6 +227,7 @@ class StreamSourceTest extends AsyncTestCase
|
||||
$stream = $this->source->stream();
|
||||
$promise = $this->source->emit(1);
|
||||
unset($stream);
|
||||
$this->assertTrue($this->source->isDisposed());
|
||||
$this->assertNull(yield $promise);
|
||||
yield $this->source->emit(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user