Skip to content

Instantly share code, notes, and snippets.

@klovadis
Created November 18, 2012 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klovadis/4108171 to your computer and use it in GitHub Desktop.
Save klovadis/4108171 to your computer and use it in GitHub Desktop.
Example of synchroneous flow
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