Urara-Blog/node_modules/.pnpm-store/v3/files/b4/1d9f84c72ff2d04f16fa866cf614b5fb3288c33ffec511b007f1f4586ebec31b5077ad32bbf676b4b7f79ba047121fd6987758c0ff55599fc9bc84b844147f
2022-08-14 01:14:53 +08:00

36 lines
1.1 KiB
Text

/*
Copyright 2018 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import { Queue } from './Queue.js';
import './_version.js';
/**
* A class implementing the `fetchDidFail` lifecycle callback. This makes it
* easier to add failed requests to a background sync Queue.
*
* @memberof workbox-background-sync
*/
class BackgroundSyncPlugin {
/**
* @param {string} name See the {@link workbox-background-sync.Queue}
* documentation for parameter details.
* @param {Object} [options] See the
* {@link workbox-background-sync.Queue} documentation for
* parameter details.
*/
constructor(name, options) {
/**
* @param {Object} options
* @param {Request} options.request
* @private
*/
this.fetchDidFail = async ({ request }) => {
await this._queue.pushRequest({ request });
};
this._queue = new Queue(name, options);
}
}
export { BackgroundSyncPlugin };