The issue is that if the listen() is called multiple times. The callback gets overwritten but , we now have two onData events registered.
The proposal to change is this, so that onData is registered on the reader when the instance is created, and not on listen. Also, the dispose removes callback, and not the onData handler.
For efficiency, we don't need to process data unless there is a listener on. So, adding a isEmpty to the Emitter, and using emitter to manage callbacks and cleanup.
The issue is that if the
listen()is called multiple times. Thecallbackgets overwritten but , we now have twoonDataevents registered.The proposal to change is this, so that
onDatais registered on the reader when the instance is created, and not onlisten. Also, the dispose removes callback, and not theonDatahandler.For efficiency, we don't need to process data unless there is a listener on. So, adding a
isEmptyto theEmitter, and using emitter to manage callbacks and cleanup.