From 1fac9048d18156027856c7af3209b34fc94b24e6 Mon Sep 17 00:00:00 2001 From: Michael Ridgway Date: Fri, 14 Nov 2014 23:11:53 -0800 Subject: [PATCH] [resolves #34] Allow param to be passed to emitChange events; Default to the store instance instead of the store class --- utils/BaseStore.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/BaseStore.js b/utils/BaseStore.js index ed54a48..4edab59 100644 --- a/utils/BaseStore.js +++ b/utils/BaseStore.js @@ -28,7 +28,7 @@ util.inherits(BaseStore, EventEmitter); * @method addChangeListener * @param {Function} callback */ -BaseStore.prototype.addChangeListener = function(callback) { +BaseStore.prototype.addChangeListener = function addChangeListener(callback) { this.on(CHANGE_EVENT, callback); }; @@ -37,16 +37,17 @@ BaseStore.prototype.addChangeListener = function(callback) { * @method removeChangeListener * @param {Function} callback */ -BaseStore.prototype.removeChangeListener = function(callback) { +BaseStore.prototype.removeChangeListener = function removeChangeListener(callback) { this.removeListener(CHANGE_EVENT, callback); }; /** * Emit a change event * @method emitChange + * @param {*} param=this */ -BaseStore.prototype.emitChange = function() { - this.emit(CHANGE_EVENT, this.constructor); +BaseStore.prototype.emitChange = function emitChange(param) { + this.emit(CHANGE_EVENT, param || this); }; module.exports = BaseStore;