Skip to content

How to run action itself in that action? #1943

Answered by EmilTholin
baeharam asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @baeharam!

You could put your flows in standalone variables in the scope first and return them afterwards. This way you can references them.

Example

types.model("Example").actions((self) => {
  const fetcherB = flow(function* () {
    // ...
  });
  const fetcherA = flow(function* () {
    // ...
    try {
      // ...
    } catch (error) {
      if (error === AUTH_ERROR) {
        yield fetcherB();
        yield fetcherA();
      }
    }
  });

  return {
    fetcherA,
    fetcherB,
  };
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@baeharam
Comment options

Answer selected by baeharam
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants