Closed
Description
What problem does this feature solve?
The "subscribeAction.after" is not run if an action throws an error.
What does the proposed API look like?
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);
}
});
};
Activity
ktsn commentedon May 30, 2019
It would make more sense if the handler name is just
error
for consistency.milesingrams commentedon Aug 10, 2019
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.
de-don commentedon Aug 14, 2019
Thanks, I updated my example.
evgeniy-legkun commentedon Nov 12, 2019
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 ...
milesingrams commentedon Nov 18, 2019
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.
samuelhgf commentedon Jan 15, 2020
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?
verhichi commentedon Jan 27, 2020
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.
[-]Add handler "subscribeAction.onError"[/-][+]Add handler "subscribeAction.error"[/+]rodrigoj42 commentedon Jan 27, 2020
I'm using https://github.com/VitorLuizC/vuex-handler
samuelhgf commentedon Jan 28, 2020
@verhichi I'm catching any error with onError function from apollo-link-error. The setup is on ApolloClient.
verhichi commentedon Jan 29, 2020
@samuelhgf
Yeah, that's the approach I went with too.
The only difference being I'm using REST so axios instead of apollo.
kiaking commentedon Apr 30, 2020
This issue is in progress at #1531.
feat: Allow action subscribers to catch rejections. (#1740)
kiaking commentedon May 8, 2020
This has been added via #1740 👍