Re: [w3c/ServiceWorker] New "setup" lifecycle for service worker (#1576)

Seems like the extension service worker is different enough that it could have its own rules, if it wanted. Or, if it wanted to stick with service worker rules, this format works in both:

```js
const setup = Promise.all([
  asyncThing1(),
  asyncThing2(),
]);

addEventListener('fetch', (event) => {
  event.respondWith((async () => {
    const [thing1, thing2] = await setup;
    // …
  })());
});
```

The above pattern has advantages: Particular events wouldn't need to wait for `setup` if they don't need it, or setup requirements could be more granular, where some events don't need to await everything in the setup.

-- 
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/1576#issuecomment-815542195

Received on Thursday, 8 April 2021 07:57:31 UTC