all files / src/network/helpers/ notifications.js

80.77% Statements 21/26
66.67% Branches 4/6
42.86% Functions 3/7
82.61% Lines 19/23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44                                                 
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.invalidateSimulation = invalidateSimulation;
exports.onSimulationChange = onSimulationChange;
exports.invalidateProject = invalidateProject;
exports.onProjectChange = onProjectChange;
 
var _monologue = require('monologue.js');
 
var _monologue2 = _interopRequireDefault(_monologue);
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
function _classCallCheck(instance, Constructor) { Iif (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 
var Observable = function Observable() {
  _classCallCheck(this, Observable);
};
 
_monologue2.default.mixInto(Observable);
 
var notification = new Observable();
var SIMULATION_CHANGE = 'data.simulation.change';
var PROJECT_CHANGE = 'data.project.change';
 
function invalidateSimulation(simulation) {
  notification.emit(SIMULATION_CHANGE, simulation);
}
 
function onSimulationChange(cb) {
  return notification.on(SIMULATION_CHANGE, cb);
}
 
function invalidateProject(project) {
  notification.emit(PROJECT_CHANGE, project);
}
 
function onProjectChange(cb) {
  return notification.on(PROJECT_CHANGE, cb);
}