2016-05-24 18:47:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp;
|
|
|
|
|
2016-05-29 18:35:09 +02:00
|
|
|
use Interop\Async\Awaitable;
|
|
|
|
|
2016-06-01 18:37:12 +02:00
|
|
|
/**
|
|
|
|
* Represents a set of asynchronous values. An observable is analogous to an asynchronous generator, yielding (emitting)
|
|
|
|
* values when they are available, returning a value (success value) when the observable completes or throwing an
|
|
|
|
* exception (failure reason).
|
|
|
|
*/
|
2016-05-29 18:35:09 +02:00
|
|
|
interface Observable extends Awaitable {
|
2016-05-24 18:47:14 +02:00
|
|
|
/**
|
2016-05-27 22:44:01 +02:00
|
|
|
* Registers a callback to be invoked each time value is emitted from the observable. If the function returns an
|
2016-06-01 18:37:12 +02:00
|
|
|
* awaitable, back-pressure is applied to the awaitable until the returned awaitable is resolved.
|
2016-05-27 01:20:05 +02:00
|
|
|
*
|
2016-05-27 22:44:01 +02:00
|
|
|
* Exceptions thrown from $onNext (or failures of awaitables 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
|
|
|
*
|
|
|
|
* @param callable $onNext Function invoked each time a value is emitted from the observable.
|
|
|
|
*
|
2016-06-02 17:35:41 +02:00
|
|
|
* @return \Amp\Subscriber
|
2016-05-24 18:47:14 +02:00
|
|
|
*/
|
2016-08-11 21:35:58 +02:00
|
|
|
public function subscribe(callable $onNext): Subscriber;
|
2016-05-24 18:47:14 +02:00
|
|
|
}
|