You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
641 B

var State = require('./State');
var actions = Object.create(null);
/**
*
*/
module.exports = {
level: 0,
subscribe(event, callback) {
if (actions[event] === undefined) {
actions[event] = [];
}
actions[event].push(callback);
},
publish(event) {
if (actions[event] === undefined) {
return;
}
var args = Array.prototype.slice.call(arguments, 1);
actions[event].forEach(function(callback) {
callback.apply(null, args);
});
}
};
module.exports.subscribe('level/complete', function() {
module.exports.level++;
});