Skip to content

Instantly share code, notes, and snippets.

@Olical
Last active August 29, 2015 13:58
Show Gist options
  • Save Olical/10275240 to your computer and use it in GitHub Desktop.
Save Olical/10275240 to your computer and use it in GitHub Desktop.
Absolutely tiny emitter.
function e(m,i,t){return m.map(function(l){return l(i,m)})}
var someObj = {
onSomeEvent: []
};
someObj.onSomeEvent.push(function (message) {
console.log('Message was', message, this.suffix);
});
e(someObj.onSomeEvent, ['A MESSAGE'], {
suffix: '[This is from the scope!]'
});
// Result: Message was A MESSAGE [This is from the scope!]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment