react-native-global-event-emitter icon indicating copy to clipboard operation
react-native-global-event-emitter copied to clipboard

Optimizations and bug fix

Open DickyT opened this issue 9 years ago • 1 comments

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.

DickyT avatar Jan 24 '16 08:01 DickyT

Looks good @DickyT. Just two tiny comments, and we can merge it in.

paramaggarwal avatar Jan 24 '16 15:01 paramaggarwal