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

How can this be used with for instance react hooks? #18

Open
EloB opened this issue Nov 4, 2020 · 1 comment
Open

How can this be used with for instance react hooks? #18

EloB opened this issue Nov 4, 2020 · 1 comment

Comments

@EloB
Copy link

EloB commented Nov 4, 2020

I really starting to like this library.

One thing that I don't understand it how to use this with for instance useEffect in React where you have an external teardown function...

Can you provide any example how to do that? <3

@EloB
Copy link
Author

EloB commented Nov 4, 2020

useEffect(() => {
  (async () => {
    for (const event subscribe.call(instance, 'something')) {
      // Do something
    }
  })();
  return () => {
    // Teardown function
    // Is it possible to teardown that asyncIterator somehow?
  };
})

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