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

Emit close event once we reach the end of the stream #24

Merged

Conversation

WyriHaximus
Copy link
Member

No description provided.

@@ -102,6 +102,9 @@ protected function performRead($chunkSize)
$this->emit('end', [
$this,
]);
$this->emit('close', [
$this,
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Maybe call close() instead here? Could also use a test or two 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing both lines with close and calling close instead. Will also add tests to be sure everything works as intended 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved the issue, working on tests now. (It required some other related code change as well.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR updated

WyriHaximus added a commit to WyriHaximus-labs/filesystem that referenced this pull request Jun 14, 2018
…djusted a test to test the expected workflow. Follow up for reactphp#24 (comment) from @clue
$this->emit('end', [
$this,
]);
$this->close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow exactly what' supposed to happen here, but it's my understanding that this should first emit an end event immediately followed by a close? (https://github.com/reactphp/stream#end-event)

Do we have a test for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, end shouldn't be emitted from the close call. But from when we reach EOF. Adjusted code and tests to ensure the behavior is as described on https://github.com/reactphp/stream#end-event

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for looking into this, changes LGTM! 👍

For the reference: The additional $this arguments have been removed via reactphp/stream#69 a while back. This component still targets legacy stream v0.4, so I guess we may want to address this eventually.

WyriHaximus added a commit to WyriHaximus-labs/filesystem that referenced this pull request Jun 18, 2018
@WyriHaximus
Copy link
Member Author

Cool, I'll squash and merge soon 👍

@WyriHaximus WyriHaximus force-pushed the readable-stream-trait-emit-close branch from 40c95fb to 2b9907e Compare June 19, 2018 08:44
@WyriHaximus WyriHaximus merged commit 7112d79 into reactphp:master Jun 19, 2018
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