Created
November 18, 2012 23:39
-
-
Save klovadis/4108171 to your computer and use it in GitHub Desktop.
Example of synchroneous flow
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
var ee = new (require('events').EventEmitter)(); | |
var foo; | |
// listener function | |
ee.on('test', function (newValue) { | |
foo = newValue; | |
}); | |
// before emitting | |
foo = 'one'; | |
console.log(foo); | |
// emitting, changing value to 'two' | |
ee.emit('test', 'two'); | |
console.log(foo); | |
// after emitting | |
foo = 'three'; | |
console.log(foo); | |
// console shows one two three, just synchroneous code.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment