react-native-global-event-emitter
react-native-global-event-emitter copied to clipboard
Optimizations and bug fix
Hi there,
I noticed that inside the addListener, if someone trying to listen to an event which is already listened before, which will cause RNTGlobalEventEmitter.addObserver(eventName); run one more time, which is unnecessary to register an native listener at NSNotificationCenter.
Whats more, I added removeListenderById method, because sometimes to deal with scope issues, you need to passing a closure / code block to the addListener, which makes removeListener harder. With removeListenderById, you only need to passing the event name and the reference ID, which can get from addListener.
Looks good @DickyT. Just two tiny comments, and we can merge it in.