The "subscribeAction.after" is not run if an action throws an error.
I propose to add one more property for catching errors in actions:
const waitPlugin = (store) => {
store.subscribeAction({
before: (action) => {
console.log(action.type);
},
after: (action) => {
console.log(action.type);
},
error: (action, error) => {
console.log(action.type);
}
});
};
It would make more sense if the handler name is just error for consistency.
This would be really, really, really awesome. Been using a timeout hack to resolve issues where I don't know if an action has errored out.
It would make more sense if the handler name is just
errorfor consistency.
Thanks, I updated my example.
This is really good idea. I use subscribeAction handler to manage API calls loaders (spinners) and this feature with errors will be really useful. Waiting for it ...
Any update on this? Using this for loading spinners as well and it is critical to know if the action has failed before the after hook is called.
Hi, guys! Any solution for that? I'm having a problem with loading. The after method is not colling when happens a error. Some body @milesingrams found a solution for that?
Does anyone know how to deal with this issue as of this moment? I'm throwing in pending async process id's inside the store and am using subscribeAction to capture async actions, but errors in actions makes the after method not work.
@verhichi I'm catching any error with onError function from apollo-link-error. The setup is on ApolloClient.
@samuelhgf
Yeah, that's the approach I went with too.
The only difference being I'm using REST so axios instead of apollo.
This issue is in progress at #1531.
This has been added via https://github.com/vuejs/vuex/pull/1740 馃憤
Most helpful comment
It would make more sense if the handler name is just
errorfor consistency.