Cache worker from JS to TS

This commit is contained in:
NicolasCantu 2025-02-19 16:27:42 +01:00
parent a16e984ecd
commit 60b49a65e5
2 changed files with 22 additions and 8 deletions

View File

@ -1,8 +0,0 @@
const addResourcesToCache = async (resources) => {
const cache = await caches.open('v1');
await cache.addAll(resources);
};
self.addEventListener('install', (event) => {
event.waitUntil(addResourcesToCache(['/', '/index.html', '/style.css', '/app.js', '/image-list.js', '/star-wars-logo.jpg', '/gallery/bountyHunters.jpg', '/gallery/myLittleVader.jpg', '/gallery/snowTroopers.jpg']));
});

View File

@ -0,0 +1,22 @@
declare var self: ServiceWorkerGlobalScope;
const addResourcesToCache = async (resources: string[]): Promise<void> => {
const cache = await caches.open('v1');
await cache.addAll(resources);
};
self.addEventListener('install', (event: ExtendableEvent) => {
event.waitUntil(
addResourcesToCache([
'/',
'/index.html',
'/style.css',
'/app.js',
'/image-list.js',
'/star-wars-logo.jpg',
'/gallery/bountyHunters.jpg',
'/gallery/myLittleVader.jpg',
'/gallery/snowTroopers.jpg'
])
);
});