goatslacker / alt

Isomorphic flux implementation
http://alt.js.org/
3.45k stars 323 forks source link

Inherited method in action #639

Closed maxs15 closed 8 years ago

maxs15 commented 8 years ago

It looks like the dispatch is not performed when it is called in a inherited method. I've added a test on my fork (https://github.com/maxs15/alt/commit/d61160fec1c643120980d51c8a5823c41b21284e) @goatslacker any idea what could be the issue ?

Thanks

maxs15 commented 8 years ago

I found out the issue.

By calling the fetch action directly inside my get action the dispatch will call the onFetchmethod of the store, onGet won't be called

get(id) {
   return this.fetch({get: 'app/' + id});
}

The solution is to pass the dispatch to the fetchmethod, that way onGet will be called

get(id) {
   return (dispatch) => this.fetch({get: 'app/' + id}, dispatch);
}