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

Makes FetchEventSource compatible with webworker #21

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

stefdev49
Copy link

Hello,

these changes (somehow similar to #8) are the minimal ones I had to do to get FetchEventSource working in a web worker context.
I've also added some unit tests to validate these changes.

With it one can use FetchEventSource in a WebWorker by settings these parameters :

fetchEventSource('https://myurl', {
    openWhenHidden: true,
    fetch: self.fetch,
    .....

- when openWhenHidden is true, the event listener is not added. So don't remove
  it in dispose().
  This helps the webworker use case where document does not exist, but
  can be worked around by setting openWhenHidden to true.
- self will work in both browser window and webworker context
@ghost
Copy link

ghost commented Jul 1, 2022

CLA assistant check
All CLA requirements met.

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

Successfully merging this pull request may close these issues.

1 participant