promises
promises copied to clipboard
Add splat() function
I was just writing some code that would have been greatly improved by having a splat() function that works similarly to all().
The current code is:
Promise\all($promises)->then(function ($results) {
list($first, $second) = $results;
...
});
But what I would rather write is:
Promise\splat($promises)->then(function ($first, $second) {
...
});
This would require PHP >= 5.6 for argument unpacking or the use of call_user_func_array.
There's no reason to have another then() there, just Promise\splat($promises, function ($first, $second) { ... }) should be enough.
I don't feel that this is necessary.