2016-12-29 21:09:49 +01:00
|
|
|
<?php
|
2016-08-16 06:46:26 +02:00
|
|
|
|
2016-05-24 18:47:14 +02:00
|
|
|
namespace Amp;
|
|
|
|
|
2016-06-01 18:37:12 +02:00
|
|
|
/**
|
2017-01-04 02:10:27 +01: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 18:37:12 +02:00
|
|
|
* exception (failure reason).
|
|
|
|
*/
|
2017-01-04 02:10:27 +01:00
|
|
|
interface Stream extends Promise {
|
2016-05-24 18:47:14 +02:00
|
|
|
/**
|
2017-01-04 02:10:27 +01:00
|
|
|
* Registers a callback to be invoked each time value is emitted from the stream. If the function returns an
|
2016-11-14 20:59:21 +01:00
|
|
|
* promise, back-pressure is applied to the promise until the returned promise is resolved.
|
2016-05-27 01:20:05 +02:00
|
|
|
*
|
2017-03-21 18:24:06 +01:00
|
|
|
* Exceptions thrown from $onEmit (or failures of promises returned from $onNext) will fail the returned
|
2016-06-02 17:35:41 +02:00
|
|
|
* Subscriber with the thrown exception.
|
2016-05-27 22:44:01 +02:00
|
|
|
*
|
2017-03-21 18:24:06 +01:00
|
|
|
* @param callable $onEmit Function invoked each time a value is emitted from the stream.
|
2016-05-24 18:47:14 +02:00
|
|
|
*/
|
2017-03-21 18:24:06 +01:00
|
|
|
public function onEmit(callable $onEmit);
|
2016-05-24 18:47:14 +02:00
|
|
|
}
|