summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2016-01-19 22:47:43 +0100
committerMatěj Cepl <mcepl@cepl.eu>2016-01-19 22:47:43 +0100
commit069fde886eeb9c06728eba18f765d987b5174c10 (patch)
tree773ab1269ba3877ca81694cd1675659c51062fcf
parent2334b9a2760e037889a5fcdb9aac91affa335e0a (diff)
downloadzalmy-069fde886eeb9c06728eba18f765d987b5174c10.tar.gz
An attempt to fix ServiceWorkers, but it is broken. Somewhere.
-rw-r--r--sworker.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/sworker.js b/sworker.js
index a17f8ad..ac37061 100644
--- a/sworker.js
+++ b/sworker.js
@@ -1,4 +1,4 @@
-var version = 'v35 2016-01-06';
+var version = 'v36 2016-01-19';
var toCache = [
'/',
'activePage.js',
@@ -19,22 +19,25 @@ var toCache = [
];
self.addEventListener('install', event => {
- event.waitUntil(
- caches.open('static' + version).then(c => c.addAll(toCache))
- );
+ event.waitUntil(
+ caches.open('static' + version)
+ .then(
+ c => c.addAll(toCache)
+ .then(v => console.log('********* Yay!'), e => console.log('************* Error'))
+ )
+ );
});
self.addEventListener('activate', event => {
- console.log('caches.keys() = ' + caches.keys());
- event.waitUntil(
- Promise.all(
- caches.keys().then(keys =>
- keys.filter(key => key != 'static' + version).map(key => caches.delete(key))
- )
+ event.waitUntil(caches.keys().then(
+ keys => Promise.all(
+ keys.filter(key => key != 'static' + version).
+ map(key => caches.delete(key))
+ )
)
);
});
-self.addEventListener('fetch', event => {
+self.addEventListener('fetch', function(event) {
event.respondWith(caches.match(event.request));
});