Re: [w3c/ServiceWorker] Promise on navigator.serviceWorker that resolves when page is controlled (#799)

> @jeffposnick
> 
> > there could be a new promise, perhaps named .controlled
> 
> This could be implemented as:
> 
> ```js
> const p = new Promise(r => {
>   if (navigator.serviceWorker.controller) return r();
>   navigator.serviceWorker.addEventListener('controllerchange', e => r());
> });
> ```
> 
> I think we need more evidence that this is a common enough pattern to add to the platform.

This solved our issue.  Thank you :+1:

-- 
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/799#issuecomment-931557960

Received on Thursday, 30 September 2021 18:22:03 UTC