Cache worker from JS to TS
This commit is contained in:
parent
a16e984ecd
commit
60b49a65e5
@ -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']));
|
||||
});
|
22
src/service-workers/cache.worker.ts
Normal file
22
src/service-workers/cache.worker.ts
Normal 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'
|
||||
])
|
||||
);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user