Table of Contents

Class ServiceWorkerGlobalScope

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The ServiceWorkerGlobalScope interface of the Service Worker API represents the global execution context of a service worker.

[Value("ServiceWorkerGlobalScope")]
public class ServiceWorkerGlobalScope : WorkerGlobalScope, FontFaceSource, WindowOrWorkerGlobalScope
Inheritance
ServiceWorkerGlobalScope
Implements
Inherited Members

Remarks

Developers should keep in mind that the ServiceWorker state is not persisted across the termination/restart cycle, so each event handler should assume it's being invoked with a bare, default global state.

Once successfully registered, a service worker can and will be terminated when idle to conserve memory and processor power. An active service worker is automatically restarted to respond to events, such as ServiceWorkerGlobalScope.Fetch or ServiceWorkerGlobalScope.Message.

Additionally, synchronous requests are not allowed from within a service worker — only asynchronous requests, like those initiated via the WorkerGlobalScopefetch method, can be used.

This interface inherits from the WorkerGlobalScope interface, and its parent EventTarget.

-Using Service Workers
-Service workers basic code example

See also on MDN

Constructors

ServiceWorkerGlobalScope()

public ServiceWorkerGlobalScope()

Properties

Clients

The clients read-only property of the
ServiceWorkerGlobalScope interface returns the Clients
object associated with the service worker.

[Value("clients")]
public Clients Clients { get; }

Property Value

Clients

The Clients object associated with the specific worker.

Remarks

CookieStore

The cookieStore read-only property of the ServiceWorkerGlobalScope interface returns a reference to the CookieStore object associated with this service worker.

[Value("cookieStore")]
public CookieStore CookieStore { get; }

Property Value

CookieStore

A CookieStore object instance.

Remarks

Onactivate

[Value("onactivate")]
public EventHandlerNonNull Onactivate { get; set; }

Property Value

EventHandlerNonNull

Onbackgroundfetchabort

[Value("onbackgroundfetchabort")]
public EventHandlerNonNull Onbackgroundfetchabort { get; set; }

Property Value

EventHandlerNonNull

Onbackgroundfetchclick

[Value("onbackgroundfetchclick")]
public EventHandlerNonNull Onbackgroundfetchclick { get; set; }

Property Value

EventHandlerNonNull

Onbackgroundfetchfail

[Value("onbackgroundfetchfail")]
public EventHandlerNonNull Onbackgroundfetchfail { get; set; }

Property Value

EventHandlerNonNull

Onbackgroundfetchsuccess

[Value("onbackgroundfetchsuccess")]
public EventHandlerNonNull Onbackgroundfetchsuccess { get; set; }

Property Value

EventHandlerNonNull

Oncanmakepayment

[Value("oncanmakepayment")]
public EventHandlerNonNull Oncanmakepayment { get; set; }

Property Value

EventHandlerNonNull

Oncontentdelete

[Value("oncontentdelete")]
public EventHandlerNonNull Oncontentdelete { get; set; }

Property Value

EventHandlerNonNull

Oncookiechange

[Value("oncookiechange")]
public EventHandlerNonNull Oncookiechange { get; set; }

Property Value

EventHandlerNonNull

Onfetch

[Value("onfetch")]
public EventHandlerNonNull Onfetch { get; set; }

Property Value

EventHandlerNonNull

Oninstall

[Value("oninstall")]
public EventHandlerNonNull Oninstall { get; set; }

Property Value

EventHandlerNonNull

Onmessage

[Value("onmessage")]
public EventHandlerNonNull Onmessage { get; set; }

Property Value

EventHandlerNonNull

Onmessageerror

[Value("onmessageerror")]
public EventHandlerNonNull Onmessageerror { get; set; }

Property Value

EventHandlerNonNull

Onnotificationclick

[Value("onnotificationclick")]
public EventHandlerNonNull Onnotificationclick { get; set; }

Property Value

EventHandlerNonNull

Onnotificationclose

[Value("onnotificationclose")]
public EventHandlerNonNull Onnotificationclose { get; set; }

Property Value

EventHandlerNonNull

Onpaymentrequest

[Value("onpaymentrequest")]
public EventHandlerNonNull Onpaymentrequest { get; set; }

Property Value

EventHandlerNonNull

Onperiodicsync

[Value("onperiodicsync")]
public EventHandlerNonNull Onperiodicsync { get; set; }

Property Value

EventHandlerNonNull

Onpush

[Value("onpush")]
public EventHandlerNonNull Onpush { get; set; }

Property Value

EventHandlerNonNull

Onpushsubscriptionchange

[Value("onpushsubscriptionchange")]
public EventHandlerNonNull Onpushsubscriptionchange { get; set; }

Property Value

EventHandlerNonNull

Onsync

[Value("onsync")]
public EventHandlerNonNull Onsync { get; set; }

Property Value

EventHandlerNonNull

Registration

The registration read-only property of the ServiceWorkerGlobalScope interface returns a reference to the ServiceWorkerRegistration object, which represents the service worker's registration.

[Value("registration")]
public ServiceWorkerRegistration Registration { get; }

Property Value

ServiceWorkerRegistration

A ServiceWorkerRegistration object.

Remarks

ServiceWorker

The serviceWorker read-only property of the ServiceWorkerGlobalScope interface returns a reference to the ServiceWorker object, which represents the service worker.

[Value("serviceWorker")]
public ServiceWorker ServiceWorker { get; }

Property Value

ServiceWorker

A ServiceWorker object.

Remarks

Methods

SkipWaiting()

The skipWaiting() method of the ServiceWorkerGlobalScope interface forces the waiting service worker to become the active service worker.

[Value("skipWaiting")]
public Task<GlobalObject.Undefined> SkipWaiting()

Returns

Task<GlobalObject.Undefined>

A Promise that resolves with undefined after trying to activate the newly installed service worker.

Remarks

Use this method with Claim() to ensure that updates to the underlying service worker take effect immediately for both the current client and all other active clients.

-Using Service Workers
-Service workers basic code example
-Claim()
-Using web workers

See also on MDN