Skip to content

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