0

有没有办法发现哪个处理程序触发了事件?

例如,我的商店:

handlers: {
        surahReceived(payload) {
            this._surah = payload.surah;
            this.emitChange();
        },
        ayahsReceived(payload) {
            this.dispatcher.waitFor('AyahStore', function() {
                this._surah.ayahs = this.dispatcher.getStore(AyahStore).getAyahs();
            }.bind(this));
            this.emitChange();
        },
        surahListReceived(payload) {
            this._surahs = payload.surahs;
            this.emitChange();
        }
    }

当最后一个函数触发时,我的听众:

statics: {
        storeListeners: {
            _onSurahReceived: [SurahStore]
        }
    },

我想知道哪个函数触发了事件

4

1 回答 1

1

我找到了答案:

您可以将参数传递给emitChange.

例如:

surahListReceived(payload) {
            this._surahs = payload.surahs;
            this.emitChange(1);
        }

那么在你看来:

statics: {
        storeListeners: {
            _onSurahReceived: [SurahStore]
        }
    },
_onSurahReceived: function(e) {
  console.log(e) // Should be 1
}
于 2015-03-14T00:47:55.460 回答