Closed mhelvens closed 9 years ago
Yep, something like .emitEvent
in emitter object makes sense. As well as in emitter stream, at least for consistency. Will add it soon.
How about .plug
? (It does seem like Event and Pool and Bus might all bleed together a bit, though I understand they are technically different concepts.)
Not sure about this, not very easy to add, and will probably make .withHandler
(and other methods where emitter object are used) a bit heavier.
You can use .flatMap
for this. And, if you need to handle all kind of events, something like this:
stream.withHandler(function(event, emitter) {
emitter.emit(event); // emitting event object as value, so all events available in next step
}).flatMap(function(event) { ... })
It would be quite useful, for example, in a
.withHandler
handler, to be able to pass an event directly, and / or to plug a stream into an emitter:Without this, some tedious branching-code would need to be written.