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

MutationAction never commits changes, if component switched #408

Open
andredaa opened this issue May 4, 2022 · 0 comments
Open

MutationAction never commits changes, if component switched #408

andredaa opened this issue May 4, 2022 · 0 comments

Comments

@andredaa
Copy link

andredaa commented May 4, 2022

Hello :)
I encountered a problem with MutationActions, when closing/switching the component, from which the action was triggered, before the action fully resolved.
Then any functions still running on the original componenwill not get the data commited by the MutationAction, when accessing the store.

Example:
From my starting component, I use the mutationAction fetchResults to fetch 2 results.
Before the results are received, I switch to a different component, because I get bored waiting for the results to arrive and just click around.
The component from which the MutationAction was triggered is still expecting to receive the results and to run some result processing (for visualization) in the background.

Problem: When this component access the store to read the results - the result variables are still empty.
ONLY HAPPENS IF switched to another component before the mutationAction is finished.

COMPONENT

// fetch result and create new result layers
    this.$store
      .dispatch("abm/fetchResults")
      // sucessfully got result
      .then(() => {
        // this.result accesses a getter on the store variable
        console.log(this.result) // prints NULL
        debugger;  // ----> this.result in the console prints NULL; using console to access the exact same store getter as this.result -> prints the expected result

STORE
I am using the exact example provided in the ReadMe:


@MutationAction({ mutate: ["result1", "result2"] })
  async fetchResults(): Promise<SimulationResponse> {
    const response: SimulationResponse =
      await this.getResults(
        this.config,
      );

     return response
  }
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

1 participant