Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add handler "subscribeAction.error" #1558

Closed
de-don opened this issue May 29, 2019 · 12 comments
Closed

Add handler "subscribeAction.error" #1558

de-don opened this issue May 29, 2019 · 12 comments

Comments

@de-don
Copy link

de-don commented May 29, 2019

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);
    }
  });
};
@ktsn ktsn added the proposal label May 30, 2019
@ktsn
Copy link
Member

ktsn commented May 30, 2019

It would make more sense if the handler name is just error for consistency.

@milesingrams
Copy link

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
Copy link
Author

de-don commented Aug 14, 2019

It would make more sense if the handler name is just error for consistency.

Thanks, I updated my example.

@evgeniy-legkun
Copy link

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
Copy link

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
Copy link

samuelhgf commented 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
Copy link

verhichi commented 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.

@kiaking kiaking changed the title Add handler "subscribeAction.onError" Add handler "subscribeAction.error" Jan 27, 2020
@rodrigoj42
Copy link

@samuelhgf
Copy link

@verhichi I'm catching any error with onError function from apollo-link-error. The setup is on ApolloClient.

@verhichi
Copy link

@samuelhgf
Yeah, that's the approach I went with too.
The only difference being I'm using REST so axios instead of apollo.

@kiaking
Copy link
Member

kiaking commented Apr 30, 2020

This issue is in progress at #1531.

kiaking pushed a commit that referenced this issue May 8, 2020
close #1489 #1558 #1625 

Co-authored-by: Joe Plahitko <joseph.plahitko@egov.com>
@kiaking
Copy link
Member

kiaking commented May 8, 2020

This has been added via #1740 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants