How to run action itself in that action? #1943
-
THE SITUATION
To implement this process, I have to call action A in action A ( types.model("Example")
.actions((self) => ({
fetcherA: flow(function* (){
// ...some logic
try {
// ...some logic
} catch (error) {
if (error === AUTH_ERROR) {
fetcherB().then(_ => fetcherA()) // I have to call retry action(fetcherA) itself
}
}
})
})); How can I do this? Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
EmilTholin
Aug 1, 2022
Replies: 1 comment 1 reply
-
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,
};
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
baeharam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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