Skip to content

Instantly share code, notes, and snippets.

@klovadis
Created May 28, 2012 11:56
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/2818766 to your computer and use it in GitHub Desktop.
Save klovadis/2818766 to your computer and use it in GitHub Desktop.
Code flow example of the EventEmitter
// create EventEmitter instance
var myEventEmitter = new EventEmitter();
// add event listener for "test"
myEventEmitter.on('test', function ()
console.log('2');
});
// the following code will output 1 2 3
console.log('1');
myEventEmitter.emit('test');
console.log('3');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment