-
Notifications
You must be signed in to change notification settings - Fork 41
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
Consider extracting functionality into service worker and window modules? #16
Comments
I'd propose to avoid top level await wherever you can, but that doesn't mean we couldn't somehow expose a I imagine that to support this we would either
As for splitting up the Other than providing a Promise, why would one not be able to put their own if (!window.crossOriginIsolated) {
throw new Error("Oh no!")
} |
I guess it's more of a question of what you consider in-scope. Is this supposed to be:
For the second option, here's some ideas of other utils that could be included:
All of those things 👆 could also just be examples since the code to do them is so minimal. i.e.
you're right, it's very easy to copy-paste the relevant bits into your service worker. If you want to go with that I'd suggest putting at least an excerpt of whatever blog post in the readme. like |
This comment was marked as off-topic.
This comment was marked as off-topic.
Aha ok, thank you for helping me understand a bit better, maybe something like the following could do the job for displaying something without needing any additional errors or never-resolving-awaits: if (!window.crossOriginIsolated) {
const e = document.createElement("div");
e.innerText = "Please wait while the page refreshes..."
const s = e.style;
s.position = "absolute"
s.zIndex = "10000"
s.width = "100%"
s.height = "100%"
s.backgroundColor = "#FFF"
document.body.appendChild(e);
} I like the idea of having a set of examples / recipes a lot - it is great if people can copy paste snippets of code into their projects without them needing to add a dependency. For those who want a more involved integration, we can of course also link to the |
This would make it easier to compose with an existing application and service worker.
example idea that I had
cc @gzuidhof
The text was updated successfully, but these errors were encountered: