goatslacker / alt

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

source #550

Closed AlbanMinassian closed 8 years ago

AlbanMinassian commented 8 years ago

Hello

I use source. When my JWT expire, i must test in each action if status !== 401 then redirect to action AuthAction.logout. it's work fine.

But i would like to know how write like this :

// source
PostSource = alt.createSource({
  get: {
    local() {return null;},
    shouldFetch() {return true;},
    remote() {return axios.get();},

    loading: PostActions.getLoading,
    success: PostActions.getSuccess,
    error.401: AuthActions.logout  <==== redirect to this action each time if status = 401
    error: PostActions.getError  <=== another errors
  }
});

Thanks

abritinthebay commented 8 years ago

You'd have to handle that error logic in whatever action was called on failure - or code ran from the failure. They'll get the payload.

AlbanMinassian commented 8 years ago

thanks