I'd like to know what the difference between addListener and On in EventEmitter.
I think both of them allow us to add Listener to the end of listeners.
Anyhelp would be appreciate.
I'd like to know what the difference between addListener and On in EventEmitter.
I think both of them allow us to add Listener to the end of listeners.
Anyhelp would be appreciate.
This line from the documentation for addListener
should clear things up:
Alias for
emitter.on(eventName, listener)
.
Here is the description regarding that method.
1 addListener(event, listener)
Adds a listener to the end of the listeners array for the specified event. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added multiple times. Returns emitter, so calls can be chained.
2 on(event, listener)
Adds a listener to the end of the listeners array for the specified event. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of event and listener will result in the listener being added multiple times. Returns emitter, so calls can be chained.
You could get details from here
So addListener is same with on method.