Skip to content

Commit 6e961f1

Browse files
committed
Async all the things
1 parent f7b8210 commit 6e961f1

File tree

1 file changed

+24
-22
lines changed
  • source/_extensions/pwa_service_files

1 file changed

+24
-22
lines changed
Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1+
// extend this to update the service worker every push
2+
// https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Offline_Service_workers
3+
var cacheName = 'js13kPWA-v1';
4+
15
fetch('_static/cache.json')
2-
.then(response => addEventListeners(response.json()))
6+
.then(response => addEventListeners(response.json()))
37
.catch(error => {
48
console.error(error);
5-
});
6-
7-
function addEventListeners(jsonPaths) {
8-
// extend this to update the service worker every push
9-
// https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Offline_Service_workers
10-
var cacheName = 'js13kPWA-v1';
9+
});
1110

12-
self.addEventListener('install', function(e) {
13-
e.waitUntil(
14-
caches.open('frc-docs').then(function(cache) {
15-
return cache.addAll(jsonPaths);
16-
})
17-
);
18-
});
11+
self.addEventListener('install', function(e) {
12+
e.waitUntil(
13+
caches.open('frc-docs').then(function(cache) {
14+
fetch('_static/cache.json')
15+
.then(response => return cache.addAll(response.json()))
16+
.catch(error => {
17+
console.error(error);
18+
});
19+
})
20+
);
21+
});
1922

20-
self.addEventListener('fetch', function(event) {
21-
event.respondWith(
22-
caches.match(event.request).then(function(response) {
23-
return response || fetch(event.request);
24-
})
25-
);
26-
});
27-
}
23+
self.addEventListener('fetch', function(event) {
24+
event.respondWith(
25+
caches.match(event.request).then(function(response) {
26+
return response || fetch(event.request);
27+
})
28+
);
29+
});

0 commit comments

Comments
 (0)