- From: Patrick Toner <notifications@github.com>
- Date: Mon, 23 May 2022 07:02:20 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 23 May 2022 14:02:32 UTC
> For people who're reading this now (through Google search), the `workbox-window` package now includes `active` and `controlling` promises which can be used. > > Usage: > > ``` > // somewhere > import {Workbox} from 'workbox-window'; > const workbox = new Workbox('/service-worker.js'); > Thank you for this. I'm still testing but this seems to work for me. On the first page load it waits for the 'controlling' event and then on subsequent loads will look for the controller being set. ``` if ('serviceWorker' in navigator) { const wb = new Workbox(`./sw.js`) if (navigator.serviceWorker.controller) { startApp() } else { wb.addEventListener('controlling', e => { startApp() }) } wb.register() } ``` -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/799#issuecomment-1134718776 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/issues/799/1134718776@github.com>
Received on Monday, 23 May 2022 14:02:32 UTC