Re: [ServiceWorker] Timing of events relative to initial script load (#605)

There are no guarantees here, it's the same as events in a window.

You'd need to use:

```js
self.oninstall = function(event) {
  event.waitUntil(
    caches.open('my-cache').then(function(myCache) {
      myCache.add('index.html')
    })
  );
};
```

ES7 async functions make it look more like sync code:

```js
self.oninstall = function(event) {
  event.waitUntil(async function() {
    var myCache = await caches.open('my-cache');
    return myCache.add('index.html');
  });
};
```

You can use that today using either https://github.com/google/traceur-compiler or https://6to5.org/

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/605#issuecomment-70825821

Received on Wednesday, 21 January 2015 12:05:15 UTC