1
0

PWA update available notification (#42)

This commit is contained in:
konrad
2019-12-18 21:30:20 +00:00
parent 81e9eef154
commit ff0f078ee6
5 changed files with 79 additions and 4 deletions

View File

@ -0,0 +1,3 @@
{
"SW_UPDATED": "swUpdated"
}

View File

@ -19,3 +19,24 @@ workbox.routing.registerRoute(
new RegExp('.*'),
new workbox.strategies.StaleWhileRevalidate()
);
// This code listens for the user's confirmation to update the app.
self.addEventListener('message', (e) => {
if (!e.data) {
return;
}
switch (e.data) {
case 'skipWaiting':
self.skipWaiting();
break;
default:
// NOOP
break;
}
});
workbox.core.clientsClaim();
// The precaching code provided by Workbox.
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});