Re: [w3c/ServiceWorker] Provide an easier way to listen for waiting/activating/redundant Service Workers (#1247)

Alerting users of a waiting service worker might look like this:

```js
navigator.serviceWorker.ready.then(function(reg) {
  if (reg.waiting) alertUser(reg);
  reg.addEventListener('statechange', function(e) {
    if (e.target.state === 'waiting') alertUser(reg);
  });
});
```

But I'd definitely prefer a `navigator.serviceWorker.waiting` promise for this common use case, as described in #1222.

```js
navigator.serviceWorker.waiting.then(alertUser);
```

-- 
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/1247#issuecomment-351780007

Received on Thursday, 14 December 2017 17:27:19 UTC