Is it possible to unload modules in nodejs?
In other words: clear event listeners, timeouts, and intervals.
These modules are “sub-files” of my project, and i could overwrite the .on(), and .once(), but what about timeouts and intervals?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, not that I’m aware of.
You can remove all event listeners on an emitter by calling
myEmitter.removeAllListeners(). As for clearing the timeouts and intervals, callclearTimeout(timeoutName)andclearInterval(intervalName)respectively.Example:
Hopefully this helps.