Event Driven Programming - sarahduv-401-advanced-javascript/seattle-javascript-401d32 GitHub Wiki
Event Driven Programming
What is event driven programming?
- Event-Driven Programming is a logical pattern that we can choose to confine our programming within to avoid issues of complexity and collision.
Event-Driven Programming makes use of the following concepts:
- An Event Handler is a callback function that will be called when an event is triggered.
- A Main Loop listens for event triggers and calls the associated event handler for that event.
Removing event listeners
- To remove an event listener, you can use the removeListener or removeAllListeners method. However, you should note that in the built in EventEmitter (within Node), you have to pass a reference to the exact function you want to remove. Ultimately, making sure that the function is accessible from that specific place in your code.
Source: https://alligator.io/nodejs/event-driven-programming/