Skip to content

Instantly share code, notes, and snippets.

@simianhacker
Created April 24, 2014 17:46
Show Gist options
  • Save simianhacker/11263235 to your computer and use it in GitHub Desktop.
Save simianhacker/11263235 to your computer and use it in GitHub Desktop.
define(function (require) {
'use strict';
var _ = require('lodash');
var vents = {};
return {
on: function (id, cb) {
if (!_.isArray(vents[id])) {
vents[id] = [];
}
vents[id].push(cb);
},
off: function (id) {
delete vents[id];
},
trigger: function () {
var args = Array.prototype.slice.call(arguments);
var id = args.shift();
if (vents[id]) {
_.each(vents[id], function (cb) {
cb.apply(null, args);
});
}
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment