Skip to content

Add handler "subscribeAction.error" #1558

Closed
@de-don

Description

@de-don

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

ktsn commented on May 30, 2019

@ktsn
Member

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

milesingrams

milesingrams commented on Aug 10, 2019

@milesingrams

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

de-don commented on Aug 14, 2019

@de-don
Author

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

Thanks, I updated my example.

evgeniy-legkun

evgeniy-legkun commented on Nov 12, 2019

@evgeniy-legkun

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

milesingrams commented on Nov 18, 2019

@milesingrams

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

samuelhgf commented on Jan 15, 2020

@samuelhgf

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

verhichi commented on Jan 27, 2020

@verhichi

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.

changed the title [-]Add handler "subscribeAction.onError"[/-] [+]Add handler "subscribeAction.error"[/+] on Jan 27, 2020
rodrigoj42

rodrigoj42 commented on Jan 27, 2020

@rodrigoj42
samuelhgf

samuelhgf commented on Jan 28, 2020

@samuelhgf

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

verhichi

verhichi commented on Jan 29, 2020

@verhichi

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

kiaking

kiaking commented on Apr 30, 2020

@kiaking
Member

This issue is in progress at #1531.

kiaking

kiaking commented on May 8, 2020

@kiaking
Member

This has been added via #1740 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ktsn@rodrigoj42@kiaking@milesingrams@de-don

        Issue actions

          Add handler "subscribeAction.error" · Issue #1558 · vuejs/vuex