1
0
mirror of https://github.com/danog/amp.git synced 2024-12-13 09:57:25 +01:00
amp/lib/Stream.php
Aaron Piotrowski d496c9db24
Resolve promise with YieldedValue
A suggested alternative to resolving with [$yieldedValue] since static analysis (specifically Psalm) doesn't play well with that API.

Will revert if Psalm changes or we decide to resolve with [$yieldedValue] anyway.
2020-09-24 12:53:29 -05:00

32 lines
868 B
PHP

<?php
namespace Amp;
/**
* A stream is an asynchronous set of ordered values.
*
* @template-covariant TValue
*/
interface Stream
{
/**
* Succeeds with instance of {@see YieldedValue} containing the yielded value if the stream has yielded a value.
* If the stream completes the promise resolves with null. If the stream fails, the returned promise will fail with
* the same exception.
*
* @return Promise<YieldedValue|null> Resolves with null if the stream has completed.
*
* @psalm-return Promise<YieldedValue<TValue>|null>
*
* @throws \Throwable The exception used to fail the stream.
*/
public function continue(): Promise;
/**
* Disposes of the stream, indicating the consumer is no longer interested in the stream output.
*
* @return void
*/
public function dispose();
}