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++; });