clue/reactphp-flux

Implement Transformer as stream decorator

clue opened this issue · 1 comments

clue commented

Right now, the Transformer is designed to be used in a piping context. For a number of use cases, it may make more sense to use this as a "stream decorator".

In code, this essentially means the following:

- $output = $source->pipe(new Transformer($concurrency, $handler));
+ $output = Transformer::decorate($source, $concurrency, $handler);

For the most part, this can be considered just "API sugar". But this should also take care of any unexpected stream events, such as when the $source emits an error event.

clue commented

I still think that this feature makes perfect sense :+1: However, there are currently no immediate plans to build this from my end (no demand at the moment and more important outstanding issues currently), but I would be really happy to accept PRs :+1:

(If you need this for a commercial project and you want a quote, please check out my profile and send me an email)

As an alternative, I've just pushed #11 which adds a static all() helper method to await successful fulfillment of all operations from an input stream.