Re: [w3c/ServiceWorker] How do I get extendableEvent.waitUntil() to play nicely with async functions (#1237)

I would like the focus this issue to concentrate on keeping procedural programming intact. Javascript has been doing great at keeping multiple design patterns co-existing with each other. Using `await` keeps a straight forward line of execution. Using inline function nesting callbacks, I believe, will be universally frowned upon by 10 years. For good reasons unknown to me the `waitUntil()` broke the basic promise development pattern which in turn upset the await procedural style as I pointed out. I found that the missing link is the lack of the promise while inside an async function. Here is another example of a procedural style workaround:
```javascript
self.addEventListener('install', event => { event.waitUntil(installHandler(event)); });

async function installHandler(event) {
  let cache = await caches.open(cacheName);
  await cache.addAll(cacheUrls);
}
```

-- 
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/1237#issuecomment-348631373

Received on Friday, 1 December 2017 22:29:56 UTC