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

[4.x] Support iterable type for parallel() + series() + waterfall() #49

Merged
merged 2 commits into from
Jun 13, 2022

Conversation

clue
Copy link
Member

@clue clue commented Jun 13, 2022

This changeset adds support for the iterable type for parallel() + series() + waterfall(). Instead of only accepting an array, each function now also accepts instances implementing Traversable such as Iterator and Generator instances.

This is a pure feature addition that does not break BC. With these changes applied, our API is now in line with the other promise APIs (see reactphp/promise#225).

This PR targets Async v4 as the minimum API version. The same changes have been merged for Async v3 already (#45).

The first commit highlights how this is essentially only a new type definition and a call to iterator_to_array(). The second commit then takes advantage of a more iterative approach that uses less memory and also supports consuming infinite iterators if the resulting promise settles. The test suite confirms this has 100% code coverage.

Refs #41
Builds on top of #11
Refs https://twitter.com/another_clue/status/1535652835521613824 (UML of iterators in PHP)

@clue clue added the new feature New feature or request label Jun 13, 2022
@clue clue added this to the v4.0.0 milestone Jun 13, 2022
@clue clue requested a review from WyriHaximus June 13, 2022 17:42
@WyriHaximus WyriHaximus merged commit ff7a06c into reactphp:4.x Jun 13, 2022
@clue clue deleted the iterable-v4 branch June 14, 2022 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants