Interop\Async\Loop::defer PHP Méthode

defer() public static méthode

The deferred callable MUST be executed in the next tick of the event loop and before any other type of watcher. Order of enabling MUST be preserved when executing the callbacks.
public static defer ( callable $callback, mixed $data = null ) : string
$callback callable
$data mixed Arbitrary data given to the callback function as the `$data` parameter.
Résultat string An unique identifier that can be used to cancel, enable or disable the watcher.
    public static function defer(callable $callback, $data = null)
    {
        $driver = self::$driver ?: self::get();
        return $driver->defer($callback, $data);
    }

Usage Example

Exemple #1
0
 public function when(callable $onResolved)
 {
     try {
         $onResolved($this->error);
     } catch (\Throwable $e) {
         Loop::defer(function () use($e) {
             throw $e;
         });
     }
 }
All Usage Examples Of Interop\Async\Loop::defer