Sunday, 1 July 2018

Multiple listeners reading from the same stream in NodeJS

I need two different listeners to read the input coming from a readable stream. They seem to have a race condition, and I want to make sure I get this right...

When I use .on('data') - each listener gets back the same chunk and can read it.

When I use .on('readable') - the first listener to catch the event will read from the buffer, and the second listener will get an empty buffer?

Meaning I cannot use .on('readable') event when I have TWO listeners?



from Multiple listeners reading from the same stream in NodeJS

No comments:

Post a Comment