1
4

1 回答 1

3

If I don't add on('data') listerner, the _read() will not be called. Why?

The stream is paused. Assuming you are using a recent version of node.

https://nodejs.org/api/stream.html#stream_two_modes

All Readable streams begin in paused mode but can be switched to flowing mode in one of the following ways:

Adding a 'data' event handler.

Calling the stream.resume() method.

Calling the stream.pipe() method to send the data to a Writable.

BTW, to create a readable, check noms or mississippi.from

于 2016-07-05T14:00:52.360 回答