- From: dfabulich <notifications@github.com>
- Date: Thu, 14 Dec 2017 00:09:37 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 14 December 2017 00:10:04 UTC
I suggest this "prolyfill" (a forward-looking polyfill for behavior to be eventually standardized)
```js
if (!('waiting' in navigator.serviceWorker)) {
navigator.serviceWorker.waiting = new Promise(function(resolve) {
navigator.serviceWorker.ready.then(function(reg) {
function awaitStateChange() {
reg.installing.addEventListener('statechange', function() {
if (this.state === 'installed') resolve(reg);
});
}
if (reg.waiting) resolve(reg);
if (reg.installing) awaitStateChange();
reg.addEventListener('updatefound', awaitStateChange);
})
});
}
```
--
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-351566460
Received on Thursday, 14 December 2017 00:10:04 UTC