aleclarson / emitter-kit

Type-safe event handling for Swift
MIT License
567 stars 71 forks source link

listenerCount returns wrong value #44

Closed aleclarson closed 6 years ago

aleclarson commented 6 years ago

The listenerCount property of the Event class is currently computed with _listeners.count. That's not right, since the _listeners dictionary uses target identifiers for its keys; not listener identifiers.

This will get fixed at the same time as #43.

Mattijah commented 6 years ago

Should the listenerCount return number of all listeners? Sum listeners for all the targets?

aleclarson commented 6 years ago

I think it's rather useless to return all listeners of an event (but maybe I'm wrong?). Instead, we should probably just add a getListeners(target?) method for getting the array of listeners for the given target (or the array of listeners without a target if no target is given).

Then you can do event.getListeners(nil).count and the semantics are a little clearer.

aleclarson commented 6 years ago

Added getListeners in v5.2.0 🎉

ac1c9c96fba3d548c69bed012c699ed35b7ab3c5