rpn_rs/rpn_rs_gui/assets/sw.js

31 lines
723 B
JavaScript
Raw Permalink Normal View History

2023-04-14 01:34:11 -04:00
var cacheName = 'egui-template-pwa';
var filesToCache = [
'./',
'./index.html',
'./eframe_template.js',
'./eframe_template_bg.wasm',
];
2023-09-18 21:29:24 -04:00
// self.addEventListener('keydown', function (e) {
// console.log("Got keydown", e);
// e.preventDefault();
// })
2023-04-14 01:34:11 -04:00
/* Start the service worker and cache all of the app's content */
self.addEventListener('install', function (e) {
e.waitUntil(
caches.open(cacheName).then(function (cache) {
return cache.addAll(filesToCache);
})
);
});
/* Serve cached content when offline */
self.addEventListener('fetch', function (e) {
e.respondWith(
caches.match(e.request).then(function (response) {
return response || fetch(e.request);
})
);
});