8000 Added immediate control · code-tree/sw-partial-content@8d86304 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d86304

Browse files
committed
Added immediate control
1 parent ac87ab3 commit 8d86304

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

sw.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55
self.addEventListener('install', function(event){
66
event.waitUntil(
77
caches.open('test').then(function(cache){
8+
// NOTE: Only caching audio as offline support not necessary for test
89
return cache.addAll(['audio.mp3', 'ranged_audio.mp3'])
10+
}).then(function(){
11+
return self.skipWaiting()
912
})
10-
);
11-
});
13+
)
14+
})
15+
16+
17+
self.addEventListener('activate', function(event){
18+
event.waitUntil(self.clients.claim().then(function(){
19+
console.log('SW activated')
20+
}))
21+
})
1222

1323

1424
self.addEventListener('fetch', function(event){
@@ -21,8 +31,8 @@ self.addEventListener('fetch', function(event){
2131
}
2232
return fetch(event.request)
2333
})
24-
);
25-
});
34+
)
35+
})
2636

2737

2838
function rangeable_resp(request, resp){

0 commit comments

Comments
 (0)
0