From 069fde886eeb9c06728eba18f765d987b5174c10 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 19 Jan 2016 22:47:43 +0100 Subject: An attempt to fix ServiceWorkers, but it is broken. Somewhere. --- sworker.js | 25 ++++++++++++++----------- 1 file 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)); }); -- cgit