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();
파일 보기 프로젝트 열기: amphp/amp

공개 메소드들

메소드 설명
__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.