promises icon indicating copy to clipboard operation
promises copied to clipboard

Add splat() function

Open shadowhand opened this issue 10 years ago • 1 comments

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.

shadowhand avatar Oct 16 '15 21:10 shadowhand

There's no reason to have another then() there, just Promise\splat($promises, function ($first, $second) { ... }) should be enough.

kelunik avatar Aug 15 '17 05:08 kelunik

I don't feel that this is necessary.

GrahamCampbell avatar May 22 '23 07:05 GrahamCampbell