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

Simplify ThroughStream by using data callback instead of inheritance #89

Merged
merged 3 commits into from
Apr 25, 2017

Conversation

clue
Copy link
Member

@clue clue commented Apr 24, 2017

Previously, one had to extend the ThroughStream in order to implement custom filtering behavior. However, there is no public implementation of this available: http://packanalyst.com/class?q=React%5CStream%5CThroughStream

With this PR applied, one can now simply pass a callback function to its constructor like this:

$through = new ThroughStream(function ($data) {
    return json_encode($data) . PHP_EOL;
});
$through->on('data', $this->expectCallableOnceWith("[2, true]\n"));

$through->write(array(2, true));

Builds on top of #88

@clue clue added this to the v0.7.0 milestone Apr 24, 2017
@WyriHaximus WyriHaximus merged commit f4d90ca into reactphp:master Apr 25, 2017
@clue clue deleted the through-callback branch April 25, 2017 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants