Skip to content

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

@jwadhams

Description

@jwadhams

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions