ServiceWorkerGlobalScope Class

The global object of a service worker (https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope-interface): it receives the lifecycle events (install, activate) and the functional events (fetch, message) of its service worker. It runs on the thread of the service worker (see WorkerGlobalScope).

public sealed class ServiceWorkerGlobalScope : WorkerGlobalScope
Inheritance
WorkerGlobalScope ServiceWorkerGlobalScope

Properties

NameDescription
ClientsGets the clients of the service worker (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-clients).
OnActivateGets or sets the event handler of the activate event.
OnFetchGets or sets the event handler of the fetch event.
OnInstallGets or sets the event handler of the install event.
OnMessageGets or sets the event handler of the message event.
OnMessageErrorGets or sets the event handler of the messageerror event.
RegistrationGets the registration of the service worker (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-registration).
ServiceWorkerGets the service worker (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-serviceworker).

Gets the clients of the service worker (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-clients).

public Clients Clients { get; }

Gets or sets the event handler of the activate event.

public Action<Event>? OnActivate { get; set; }

Gets or sets the event handler of the fetch event.

public Action<Event>? OnFetch { get; set; }

Gets or sets the event handler of the install event.

public Action<Event>? OnInstall { get; set; }

Gets or sets the event handler of the message event.

public Action<Event>? OnMessage { get; set; }

Gets or sets the event handler of the messageerror event.

public Action<Event>? OnMessageError { get; set; }

Gets the registration of the service worker (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-registration).

public ServiceWorkerRegistration Registration { get; }

Gets the service worker (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-serviceworker).

public ServiceWorker ServiceWorker { get; }

Methods

NameDescription
SkipWaiting()Activates the service worker without waiting for the clients of the active worker to be unloaded (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-skipwaiting).

Activates the service worker without waiting for the clients of the active worker to be unloaded (https://w3c.github.io/ServiceWorker/#dom-serviceworkerglobalscope-skipwaiting).

public Task SkipWaiting()