- From: dfabulich <notifications@github.com>
- Date: Mon, 13 Nov 2017 09:13:55 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 13 November 2017 09:14:18 UTC
It's a common practice to ask users to click an "refresh" or "update" button when a new Service Worker is waiting. The normal way to actually kick off the update is to post a message to the Service Worker, arranging a convention under which the SW can call `skipWaiting()` in the Service Worker's own scope. It would be convenient if the ServiceWorker object returned by ServiceWorkerRegistration.waiting had a `skipWaiting()` method, so developers wouldn't have to configure a message listener at all. Combined with #1222, you could write code like this: ```js navigator.serviceWorker.addEventListener('controllerchange', () => window.location.reload()); navigator.serviceWorker.waiting().then(reg => { if (confirm('refresh now?')) reg.waiting.skipWaiting(); }); ``` (Uh, don't actually use `confirm()` in production; it's just convenient for this example.) -- 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/1223
Received on Monday, 13 November 2017 09:14:18 UTC