Skip to content

How to use yield for non-async function with callback? #1691

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

You must be logged in to vote

Hi @Tj3n!

Have you looked into runInAction? It might fit your use case nicely.

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;
}

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Tj3n
Comment options

@Tj3n
Comment options

@EmilTholin
Comment options

Answer selected by Tj3n
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