Created
March 31, 2019 14:03
-
-
Save mimiz/e6a8914807e68a268599761cd9ac2def to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const EventEmitter = require('events'); | |
const myEmitter = new EventEmitter(); | |
let value = 1; | |
myEmitter.on('event', () => { | |
value = 2 | |
}); | |
myEmitter.on('event', () => { | |
value += 2 | |
}); | |
myEmitter.emit('event'); | |
console.log(value); // This will print 4. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment