How to use yield for non-async function with callback? #1691
-
Hi, I'm having a case where I tried to use Firestore realtime listener inside an action, while this works, I have to create extra actions to update back into my model, is there anyway to handle this more elegantly? Thanks in advanced. Here's some code for inspection:
In UserStore's action:
|
Beta Was this translation helpful? Give feedback.
Answered by
EmilTholin
Apr 12, 2021
Replies: 1 comment 3 replies
-
Hi @Tj3n! Have you looked into subscribeExtraInfo: () => {
const unsubscribe = subscribeUserProfile(self.authInfo.uid, (data, error) => {
if (error) {
console.log(error);
}
if (data) {
runInAction(() => {
// Do the logic in self.updateExtraInfo directly inline here instead.
});
}
});
return unsubscribe;
} |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Tj3n
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @Tj3n!
Have you looked into
runInAction
? It might fit your use case nicely.