Created
October 18, 2020 18:14
-
-
Save ugultopu/2f3b861276cd9335f44e61f79724d967 to your computer and use it in GitHub Desktop.
An example that demonstrates how to create a custom event in NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credits: https://youtu.be/ENrzD9HAZK4?t=403 | |
const { EventEmitter } = require('events'); | |
const eventEmitter = new EventEmitter(); | |
eventEmitter.on('lunch', () => { | |
console.log('yum 🍣'); | |
}); | |
eventEmitter.emit('lunch'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment