ServiceWorkerGlobalScope.onperiodicsync

Draft: This page is not complete.

The onperiodicsync property of the ServiceWorkerGlobalScope interface is an event handler fired at timed intervals, specified when registering a PeriodicSyncManager.

Syntax

ServiceWorkerGlobalScope.onperiodicsync = function(event) { ... };

Examples

The following example shows how to respond to a periodic sync event in the service worker.

self.addEventListener('periodicsync', event => {
  if (event.tag == 'get-latest-news') {
    event.waitUntil(fetchAndCacheLatestNews());
  }
});

Specifications

Specification
Web Periodic Background Synchronization
# dom-serviceworkerglobalscope-onperiodicsync

Browser compatibility

BCD tables only load in the browser

See also