How to use the workbox-background-sync/BackgroundSyncPlugin.js.BackgroundSyncPlugin function in workbox-background-sync

To help you get started, we’ve selected a few workbox-background-sync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleChrome / workbox / packages / workbox-google-analytics / src / initialize.ts View on Github external
const initialize = (options: GoogleAnalyticsInitializeOptions = {}) => {
  const cacheName = cacheNames.getGoogleAnalyticsName(options.cacheName);

  const bgSyncPlugin = new BackgroundSyncPlugin(QUEUE_NAME, {
    maxRetentionTime: MAX_RETENTION_TIME,
    onSync: createOnSyncCallback(options),
  });

  const routes = [
    createGtmJsRoute(cacheName),
    createAnalyticsJsRoute(cacheName),
    createGtagJsRoute(cacheName),
    ...createCollectRoutes(bgSyncPlugin),
  ];

  const router = new Router();
  for (const route of routes) {
    router.registerRoute(route);
  }

workbox-background-sync

Queues failed requests and uses the Background Sync API to replay them when the network is available

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis