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