does the React\Promise\all returns the results in order? #538
-
Hello I have a question about the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, the <?php
require __DIR__ . '/vendor/autoload.php';
React\Promise\all([
'first' => new React\Promise\Promise(function (callable $resolve): void {
React\EventLoop\Loop::addTimer(0.2, fn() => $resolve(1));
}),
'second' => new React\Promise\Promise(function (callable $resolve): void {
React\EventLoop\Loop::addTimer(0.1, fn() => $resolve(2));
})
])->then(function (array $results): void {
var_dump($results);
});
https://play.phpsandbox.io/react/async/R6NgB5WAVgpx98z0 I hope this helps! 👍 If so, consider supporting this project, for example by becoming a sponsor ❤️ |
Beta Was this translation helpful? Give feedback.
Yes, the
all()
function is guaranteed to preserve the original array (or iterator) keys and their order.https://play.phpsandbox.io/re…