noccylabs/react-utilities (0.1.1)
Installation
{
"repositories": [{
"type": "composer",
"url": " "
}
]
}
composer require noccylabs/react-utilities:0.1.1
About this package
ReactPHP Utilities
Installing
$ composer set repositories.noccylabs \
'{"type":"composer","url":"https://dev.noccylabs.info/api/packages/noccylabs/composer"}'
$ composer require noccylabs/react-utilities
Functions
NoccyLabs\React\Utilities\defer(callable $callback, ?Deferred $deferred = null, ?LoopInterface $loop = null)
This function is generally an alias for Loop::futureTick
. However, you can pass
it a Deferred
, in which case it will be resolved with the return value of the
callback. You can also provide a custom LoopInterface
.
NoccyLabs\React\Utilities\enqueue(callable $callback)
This function is a concurrency-friendly alternative to defer. If there is already a callback in the futureTick queue, this callback will be pushed to the end of an internal queue. Whenever an enqueued() callback is evaluated, if there is another callback in the queue, the next callback will be moved to the futureTick queue.
If you add 10 callbacks with defer()
(or Loop::futureTick()
) they will be
enqueued and evaluated one after another, effectively immediately. This will block
any yielding, and any other code-path that makes use of defer()
will have to wait
until the previous 10 callbacks have been evaluated.
Dependencies
Dependencies
ID | Version |
---|---|
react/event-loop | ^1.5 |
react/promise | ^3.2 |