1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 21:31:18 +01:00

Add StreamSource::isDisposed()

This commit is contained in:
Aaron Piotrowski 2020-07-17 11:22:13 -05:00
parent 3fb87e2c18
commit ee76c97c51
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
3 changed files with 18 additions and 0 deletions

View File

@ -226,6 +226,14 @@ final class EmitSource
return $this->completed; return $this->completed;
} }
/**
* @return bool True if the stream was disposed.
*/
public function isDisposed(): bool
{
return $this->disposed;
}
/** /**
* Completes the stream. * Completes the stream.
** **

View File

@ -56,6 +56,14 @@ final class StreamSource
return $this->source->isComplete(); return $this->source->isComplete();
} }
/**
* @return bool True if the stream has been disposed.
*/
public function isDisposed(): bool
{
return $this->source->isDisposed();
}
/** /**
* Completes the stream. * Completes the stream.
* *

View File

@ -213,6 +213,7 @@ class StreamSourceTest extends AsyncTestCase
$stream = $this->source->stream(); $stream = $this->source->stream();
$promise = $this->source->emit(1); $promise = $this->source->emit(1);
$stream->dispose(); $stream->dispose();
$this->assertTrue($this->source->isDisposed());
$this->assertNull(yield $promise); $this->assertNull(yield $promise);
yield $this->source->emit(1); yield $this->source->emit(1);
} }
@ -226,6 +227,7 @@ class StreamSourceTest extends AsyncTestCase
$stream = $this->source->stream(); $stream = $this->source->stream();
$promise = $this->source->emit(1); $promise = $this->source->emit(1);
unset($stream); unset($stream);
$this->assertTrue($this->source->isDisposed());
$this->assertNull(yield $promise); $this->assertNull(yield $promise);
yield $this->source->emit(1); yield $this->source->emit(1);
} }