2016-12-29 14:09:49 -06:00
|
|
|
<?php
|
2016-08-15 23:46:26 -05:00
|
|
|
|
2016-05-24 11:47:14 -05:00
|
|
|
namespace Amp;
|
|
|
|
|
2017-01-07 13:47:45 +01:00
|
|
|
use AsyncInterop\Promise;
|
2016-05-29 11:35:09 -05:00
|
|
|
|
2016-06-01 11:37:12 -05:00
|
|
|
/**
|
2017-01-03 19:10:27 -06:00
|
|
|
* Represents a set of asynchronous values. A stream is analogous to an asynchronous generator, yielding (emitting)
|
|
|
|
* values when they are available, returning a value (success value) when the stream completes or throwing an
|
2016-06-01 11:37:12 -05:00
|
|
|
* exception (failure reason).
|
|
|
|
*/
|
2017-01-03 19:10:27 -06:00
|
|
|
interface Stream extends Promise {
|
2016-05-24 11:47:14 -05:00
|
|
|
/**
|
2017-01-03 19:10:27 -06:00
|
|
|
* Registers a callback to be invoked each time value is emitted from the stream. If the function returns an
|
2016-11-14 13:59:21 -06:00
|
|
|
* promise, back-pressure is applied to the promise until the returned promise is resolved.
|
2016-05-26 18:20:05 -05:00
|
|
|
*
|
2016-11-14 13:59:21 -06:00
|
|
|
* Exceptions thrown from $onNext (or failures of promises returned from $onNext) will fail the returned
|
2016-06-02 10:35:41 -05:00
|
|
|
* Subscriber with the thrown exception.
|
2016-05-27 15:44:01 -05:00
|
|
|
*
|
2017-01-03 19:10:27 -06:00
|
|
|
* @param callable $onNext Function invoked each time a value is emitted from the stream.
|
2016-05-24 11:47:14 -05:00
|
|
|
*/
|
2017-01-03 19:10:27 -06:00
|
|
|
public function listen(callable $onNext);
|
2016-05-24 11:47:14 -05:00
|
|
|
}
|