PHP Class Amp\Observer

Example: $observer = new Observer($observable); // $observable is an instance of \Amp\Observable while (yield $observer->next()) { $emitted = $observer->getCurrent(); } $result = $observer->getResult();
Afficher le fichier Open project: amphp/amp

Méthodes publiques

Méthode Description
__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

Method Details

__construct() public méthode

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

__destruct() public méthode

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

drain() public méthode

Returns an array of values that were not consumed by the Observer before the Observable completed.
public drain ( ) : array
Résultat array Unconsumed emitted values.

getCurrent() public méthode

Gets the last emitted value or throws an exception if the observable has completed.
public getCurrent ( ) : mixed
Résultat mixed Value emitted from observable.

getResult() public méthode

Gets the result of the observable or throws the failure reason. Also throws an exception if the observable has not completed.
public getResult ( ) : mixed
Résultat mixed Final return value of the observable.

next() public méthode

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
Résultat Interop\Async\Promise

observe() public méthode

public observe ( ) : amp\Observable
Résultat amp\Observable The observable being observed.