Re: [w3c/ServiceWorker] Provide a one-line way to listen for a waiting Service Worker (#1222)

I don't see that exposing the skip-waiting flag solves any problem at all. Either the SW skips waiting on install, in which case you probably don't want any `window` code at all (the user can just click the browser's Refresh button to refresh), or the SW doesn't, in which case the window just has to await `controllerchange`.

To be clear, the problem as I see it is that refreshing the page on upgrade requires a lot of confusing boilerplate, even for users of workbox.

Workbox can automate adding arbitrarily complicated code to the SW, but it can't automagically drop code in the window. So instead they have an "advanced recipe" in the documentation ("Offer a page reload to users") explaining how to allow users to refresh the page when the SW updates. https://developers.google.com/web/tools/workbox/guides/advanced-recipes

The "advanced recipe" links to a blog article that I wrote on the topic. https://redfin.engineering/how-to-fix-the-refresh-button-when-using-service-workers-a8e27af6df68 The article is 2,000 words long! Understanding this code requires understanding the registration API, the difference between the `statechange` event, the `updatefound` event, and the `controllerchange` event, and when to use which. That's why it's a whole lesson plan + quiz in the Udacity course.

Maybe this would be OK if refreshing the page in response to SW updates was an advanced use case that most sites don't need, but IMO refreshing on upgrade is a perfectly ordinary use case that basically everybody needs.

The general feedback I see in this thread is "ah, but refreshing is just one use case." I've said that this seems off-base, because what I'm proposing is sugar, and there are no other important use cases to desugar.

If it helps this proposal move forward, I think @gauntface's `updatestatechange` is at least better than nothing, even if it isn't as helpful as a simple `waiting` promise.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1222#issuecomment-432821879

Received on Wednesday, 24 October 2018 20:47:12 UTC