source: frontend/node_modules/workbox-background-sync/src/BackgroundSyncPlugin.ts

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 Copyright 2018 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8
9import {WorkboxPlugin} from 'workbox-core/types.js';
10import {Queue, QueueOptions} from './Queue.js';
11import './_version.js';
12
13/**
14 * A class implementing the `fetchDidFail` lifecycle callback. This makes it
15 * easier to add failed requests to a background sync Queue.
16 *
17 * @memberof workbox-background-sync
18 */
19class BackgroundSyncPlugin implements WorkboxPlugin {
20 private readonly _queue: Queue;
21
22 /**
23 * @param {string} name See the {@link workbox-background-sync.Queue}
24 * documentation for parameter details.
25 * @param {Object} [options] See the
26 * {@link workbox-background-sync.Queue} documentation for
27 * parameter details.
28 */
29 constructor(name: string, options?: QueueOptions) {
30 this._queue = new Queue(name, options);
31 }
32
33 /**
34 * @param {Object} options
35 * @param {Request} options.request
36 * @private
37 */
38 fetchDidFail: WorkboxPlugin['fetchDidFail'] = async ({request}) => {
39 await this._queue.pushRequest({request});
40 };
41}
42
43export {BackgroundSyncPlugin};
Note: See TracBrowser for help on using the repository browser.