I have a Reflux store which seems to cause an error when triggering an action:
var taskStore = Reflux.createStore({
listenables: [taskActions],
init: function(){
this.tasks = [];
this.index = {};
this.trigger(this.tasks);
},
onLoad: function(arr){
var idx = {}
arr.forEach(function(ele){
idx[ele.id] = ele
});
this.tasks = arr;
this.index = idx;
this.trigger(arr);
}
});
When the action load is called and the onLoad method triggers, it fails on the this.trigger method with Chrome saying the error is Uncaught TypeError: Cannot read property 'apply' of undefined
The call stack eventually gets me to the Reflux listen method:
listen: function(callback, bindContext) {
bindContext = bindContext || this;
var eventHandler = function(args) {
callback.apply(bindContext, args);
}, me = this;
this.emitter.addListener(this.eventLabel, eventHandler);
return function() {
me.emitter.removeListener(me.eventLabel, eventHandler);
};
},
It's the callback in callback.apply, but it looks like that callback is undefined for some reason .
I'm clearly doing something wrong to trigger such a deep error, but I don't know what. Can someone tell me what it is that I'm doing wrong in my store?
Aucun commentaire:
Enregistrer un commentaire