React\Promise\PromiseInterface::then PHP 메소드

then() 공개 메소드

public then ( callable $onFulfilled = null, callable $onRejected = null ) : React\Promise\PromiseInterface
$onFulfilled callable
$onRejected callable
리턴 React\Promise\PromiseInterface
    public function then(callable $onFulfilled = null, callable $onRejected = null);

Usage Example

 /**
  * Create a new file driven handler instance.
  *
  * @param \Illuminate\Filesystem\Filesystem $files
  * @param React\EventLoop\LoopInterface $loop
  * @param string $path
  * 
  * @return void
  */
 public function __construct(Factory $factory, LoopInterface $loop, Server $server, $lifetime)
 {
     $this->factory = $factory;
     $this->lifetime = $lifetime;
     $this->server = $server;
     $this->loop = $loop;
     // PING redis connection every 5 minutes
     // and try to reconnect on connection error
     $this->timer = $loop->addPeriodicTimer(60 * 1, function () use($server) {
         $this->promise->then(function ($client) use($server) {
             $client->PING()->then(function ($pong) use($server) {
                 $server->log('Redis server responded ping with: %s', [$pong]);
                 return $pong == 'PONG';
             }, function ($e) {
                 return $this->reconnectByError($e);
             });
         });
     });
     // server statistics for redis connection
     $this->loop->addPeriodicTimer(60 * 30, function () {
         $this->server->log('Server statistics to the last 30 minutes.');
         $this->server->log('Best time of %fs, poor time of %fs and a average of %f seconds for total %d requests.', array_values($this->statistics));
         $this->statistics = array('best' => 0, 'poor' => 0, 'avg' => 0, 'total' => 0);
     });
 }
All Usage Examples Of React\Promise\PromiseInterface::then
PromiseInterface