UNPKG

mojio-js-sdk

Version:

Mojio javascript REST client.

67 lines (57 loc) 2.03 kB
// Generated by CoffeeScript 1.10.0 (function() { var SignalRRegistry, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; module.exports = SignalRRegistry = (function() { SignalRRegistry.prototype.observer_callbacks = {}; function SignalRRegistry() { this.observer_registry = bind(this.observer_registry, this); this.hubs = {}; SignalRRegistry.__super__.constructor.call(this); } SignalRRegistry.prototype.observer_registry = function(entity) { var callback, i, j, len, len1, ref, ref1, results, results1; if (this.observer_callbacks[entity._id]) { ref = this.observer_callbacks[entity._id]; results = []; for (i = 0, len = ref.length; i < len; i++) { callback = ref[i]; results.push(callback(entity)); } return results; } else if (this.observer_callbacks[entity.Type]) { ref1 = this.observer_callbacks[entity.Type]; results1 = []; for (j = 0, len1 = ref1.length; j < len1; j++) { callback = ref1[j]; results1.push(callback(entity)); } return results1; } }; SignalRRegistry.prototype.setCallback = function(id, futureCallback) { if (this.observer_callbacks[id] == null) { this.observer_callbacks[id] = []; } this.observer_callbacks[id].push(futureCallback); }; SignalRRegistry.prototype.removeCallback = function(id, pastCallback) { var callback, i, len, ref, temp; if (pastCallback === null) { this.observer_callbacks[id] = []; } else { temp = []; ref = this.observer_callbacks[id]; for (i = 0, len = ref.length; i < len; i++) { callback = ref[i]; if (callback !== pastCallback) { temp.push(callback); } } this.observer_callbacks[id] = temp; } }; return SignalRRegistry; })(); }).call(this); //# sourceMappingURL=SignalRRegistry.js.map