handleOpen () { this.connected = true; this.ping_interval = setInterval(this.sendPing, PING_INTERVAL_TIMEOUT); EventEmitter.prototype.emit.call(this, 'connect'); }
assign({}, EventEmitter.prototype, { getAll: function () { return _todos; }, emitChange: function() { this.emit(CHANGE_EVENT); }, addChangeListener: function(callback) { this.on(CHANGE_EVENT, callback); }, removeChangeListener: function(callback) { this.removeListener(CHANGE_EVENT, callback); } })
handleEvent (message) { EventEmitter.prototype.emit.call(this, message.event_type, message.payload); }
assign({}, EventEmitter.prototype, { // Allow Controller-View to register itself with store addChangeListener: function(callback) { this.on(Constants.CHANGE_EVENT, callback); }, removeChangeListener: function(callback) { this.removeListener(Constants.CHANGE_EVENT, callback); }, // triggers change listener above, firing controller-view callback emitChange: function() { this.emit(Constants.CHANGE_EVENT); } })
handleClose (code, reason) { this.connected = false; clearInterval(this.ping_interval); EventEmitter.prototype.emit.call(this, 'disconnect', String(reason + ' (' + code + ')')); }
handleError (error) { EventEmitter.prototype.emit.call(this, 'error', error); }