Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $config to the signatures of Utils::all and Each::of ? #147

Open
jwadhams opened this issue Nov 23, 2021 · 0 comments
Open

Add $config to the signatures of Utils::all and Each::of ? #147

jwadhams opened this issue Nov 23, 2021 · 0 comments

Comments

@jwadhams
Copy link

Description
Does it make sense to add $config as a third optional parameter to Utils::all, so that callers have more control over the underlying EachPromise (like concurrency)?

Example
Current code: (this is based on my understanding of Utils::all, unrolled so I can pass $config to EachPromise. If I'm doing this the hard way, this whole request could be moot)

$everything = [];
return (new EachPromise($requestPromises, [
    'concurrency' => 5,
    'fulfilled' => function ($oneResult) use (&$everything) {
        $everything = array_merge($everything, $oneResult);
    },
]))
    ->promise()
    ->then(function () use (&$everything) {
         return $everything;
    });

Desired code:

return Utils::all($requestPromises, false, ['concurrency' => 5])->then(function ($results)  {
    return array_merge(...$results);
});

Additional context
I'd be happy to submit a PR for this, I mostly wanted some advice if this is even a good idea, in line with how you want the library to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant