Nanobus#listeners should always include star listeners
Closed this issue · 5 comments
The Nanobus#listeners
function doesn't include star listeners when I request the listeners for an event name.
For example, I would expect that if I add a star listener to the bus, then it should be included when I request the listeners for any event. Technically there is a listener on the bus, it's just not waiting for a specific event name.
bus.on('*', function (a) { ... })
bus.on('foo', function (a) { ... })
bus.listeners('foo') // [function, function]
bus.listeners('bar') // [function]
Whats the use case here? Cleaning up old listeners? What you are saying makes sense though, one may expect that, unless specified one way or the other.
My use case is checking if I have already subscribed a *
listener to a bus. If the listeners
function doesn't include them, then I have no way of checking.
Judging by the listeners
function you could just do bus.listeners('*')
.
But what I do agree about is that the README should include language specifying that *
events are not included in listeners
or removed when removeAllListeners
is called with an eventName
other than '*'
.
Fair enough, I guess updating the README would make things clearer.