Reputation: 117
I'm trying to implement a writable stream in Node.js. I was reading through SubStack's excellent stream handbook. I was wondering whether there's a way to find out inside the writable stream when the read stream has stopped writing (when it calls push(null))? Is it OK for the implementation of a writable stream to subscribe to the finish event?
Upvotes: 1
Views: 1159
Reputation: 13598
No reason why not subscribe to end
event. It's in the contract, regardless of who consumes it.
Some of the streams referenced in the handbook you mention do that themselves. For example:
https://github.com/Raynos/duplexer/blob/master/index.js#L36
Upvotes: 1