Amp\Internal\PrivateObservable::__construct PHP Method

__construct() public method

public __construct ( callable $emitter )
$emitter callable
    public function __construct(callable $emitter)
    {
        /**
         * Emits a value from the observable.
         *
         * @param mixed $value
         *
         * @return \Interop\Async\Promise
         */
        $emit = function ($value = null) : Promise {
            return $this->emit($value);
        };
        /**
         * Completes the observable with the given value.
         *
         * @param mixed $value
         */
        $resolve = function ($value = null) {
            $this->resolve($value);
        };
        /**
         * Fails the observable with the given exception.
         *
         * @param \Throwable $reason
         */
        $fail = function (\Throwable $reason) {
            $this->fail($reason);
        };
        try {
            $emitter($emit, $resolve, $fail);
        } catch (\Throwable $exception) {
            $this->fail($exception);
        }
    }
PrivateObservable