Last active
August 29, 2015 14:08
-
-
Save jgermade/88ff8012ad0384c7ede3 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/dovoru
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 _Emitter (name) { | |
this.callers = {}; | |
} | |
_Emitter.prototype.add = function () { | |
this.callers[this.name] = true; | |
}; | |
_Emitter.prototype.log = function () { | |
console.log(JSON.stringify(this.callers)); | |
}; | |
// inherited | |
function Emitter (name) { | |
this.name = name; | |
} | |
Emitter.prototype = new _Emitter(); | |
// tests | |
var common = new Emitter(), | |
foo = new Emitter('foo'), | |
bar = new Emitter('bar'); | |
foo.add(); | |
bar.add(); | |
common.log(); | |
// | |
// Recource.on('update', '087td08d7t0d78td073y3y893y', function () {}); | |
// | |
// Recource.on('update', 'any', function () {}); | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
console output:
"{"foo":true,"bar":true}"