8000 Using a sources loading() call in a dispatch · Issue #654 · goatslacker/alt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Using a sources loading() call in a dispatch #654
Open
@fleshgolem

Description

@fleshgolem

I have setup a store with a corresponding source and some action. In this store I have the following bound method:

onLogin() {
    if (!this.getInstance().isLoading()) {
      this.getInstance().performLogin();
    }
  }

My source looks like this:

const AuthSource = {
  performLogin: {
    remote(state) {
      return axios.post(api.apiURL("/login"));
    },
    local(state) {
      return null;
    },
    loading: AuthActions.loggingIn,
    success: AuthActions.loginSuccess,
    error: AuthActions.loginFail
  }

};

I don't feel like I deviated from the doc on sources in any way. Still, i get "Uncaught Error: Invariant Violation: Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.". That error kind of make sense since I'm in the middle of the login dispatch, but from the docs I still don't get any idea on how I should handle this.

From how I understand the async example this should happen there as well, since it calls isLoading() from a dispatch callback (onSearch).

If i comment out loading: AuthActions.loggingIn everything works fine, if you disregard the fact that I have no loading action anymore

Is there any more to it that is not covered by the docs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0