-
-
Save Olical/10275240 to your computer and use it in GitHub Desktop.
Absolutely tiny emitter.
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
function e(m,i,t){return m.map(function(l){return l(i,m)})} |
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 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