source: frontend/node_modules/workbox-recipes/src/warmStrategyCache.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 815 bytes
Line 
1import {Strategy} from 'workbox-strategies/Strategy.js';
2
3import './_version.js';
4
5export interface WarmStrategyCacheOptions {
6 urls: Array<string>;
7 strategy: Strategy;
8}
9
10// Give TypeScript the correct global.
11declare let self: ServiceWorkerGlobalScope;
12
13/**
14 * @memberof workbox-recipes
15
16 * @param {Object} options
17 * @param {string[]} options.urls Paths to warm the strategy's cache with
18 * @param {Strategy} options.strategy Strategy to use
19 */
20function warmStrategyCache(options: WarmStrategyCacheOptions): void {
21 self.addEventListener('install', (event) => {
22 const done = options.urls.map(
23 (path) =>
24 options.strategy.handleAll({
25 event,
26 request: new Request(path),
27 })[1],
28 );
29
30 event.waitUntil(Promise.all(done));
31 });
32}
33
34export {warmStrategyCache};
Note: See TracBrowser for help on using the repository browser.