PHP Класс Amp\Observer

Example: $observer = new Observer($observable); // $observable is an instance of \Amp\Observable while (yield $observer->next()) { $emitted = $observer->getCurrent(); } $result = $observer->getResult();
Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( amp\Observable $observable )
__destruct ( ) Marks the observer as resolved to relieve back-pressure on the observable.
drain ( ) : array Returns an array of values that were not consumed by the Observer before the Observable completed.
getCurrent ( ) : mixed Gets the last emitted value or throws an exception if the observable has completed.
getResult ( ) : mixed Gets the result of the observable or throws the failure reason. Also throws an exception if the observable has not completed.
next ( ) : Interop\Async\Promise Succeeds with true if an emitted value is available by calling getCurrent() or false if the observable has resolved. If the observable fails, the returned promise will fail with the same exception.
observe ( ) : amp\Observable

Описание методов

__construct() публичный метод

public __construct ( amp\Observable $observable )
$observable amp\Observable

__destruct() публичный метод

Marks the observer as resolved to relieve back-pressure on the observable.
public __destruct ( )

drain() публичный метод

Returns an array of values that were not consumed by the Observer before the Observable completed.
public drain ( ) : array
Результат array Unconsumed emitted values.

getCurrent() публичный метод

Gets the last emitted value or throws an exception if the observable has completed.
public getCurrent ( ) : mixed
Результат mixed Value emitted from observable.

getResult() публичный метод

Gets the result of the observable or throws the failure reason. Also throws an exception if the observable has not completed.
public getResult ( ) : mixed
Результат mixed Final return value of the observable.

next() публичный метод

Succeeds with true if an emitted value is available by calling getCurrent() or false if the observable has resolved. If the observable fails, the returned promise will fail with the same exception.
public next ( ) : Interop\Async\Promise
Результат Interop\Async\Promise

observe() публичный метод

public observe ( ) : amp\Observable
Результат amp\Observable The observable being observed.