how to remove in real projects?
In such usecases, no need to remove event listeners and once can be used. But, If you need to remove listeners, you can use removeListener and the listener function should be defined on its own like:
once
removeListener
const eventHandler = () => { /* Logic */ }; Eventemitter.on("EVENT_NAME", eventHandler); EventEmitter.removeListener("EVENT_NAME", eventHandler);
What do you mean?
How to properly remove event listeners in node js eventemitter?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
how to remove in real projects?
In such usecases, no need to remove event listeners and
once
can be used.But, If you need to remove listeners, you can use
removeListener
and the listener function should be defined on its own like:What do you mean?
How to properly remove event listeners in node js eventemitter?