Skip to content

Conversation

@clue
Copy link
Member

@clueclue 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)

@clueclue added the new feature New feature or request label Jun 13, 2022
@clueclue added this to the v4.0.0 milestone Jun 13, 2022
@clueclue requested a review from WyriHaximusJune 13, 2022 17:42
@WyriHaximusWyriHaximus merged commit ff7a06c into reactphp:4.xJun 13, 2022
@clueclue deleted the iterable-v4 branch June 14, 2022 07:37
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new featureNew feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@clue@WyriHaximus