How to use the workbox-routing/Router.js.Router function in workbox-routing

To help you get started, we’ve selected a few workbox-routing 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);
  }

  router.addFetchListener();
};

workbox-routing

A service worker helper library to route request URLs to handlers.

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis