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.
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
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
Onbackgroundfetchabort
[Value("onbackgroundfetchabort")]
public EventHandlerNonNull Onbackgroundfetchabort { get; set; }
Property Value
Onbackgroundfetchclick
[Value("onbackgroundfetchclick")]
public EventHandlerNonNull Onbackgroundfetchclick { get; set; }
Property Value
Onbackgroundfetchfail
[Value("onbackgroundfetchfail")]
public EventHandlerNonNull Onbackgroundfetchfail { get; set; }
Property Value
Onbackgroundfetchsuccess
[Value("onbackgroundfetchsuccess")]
public EventHandlerNonNull Onbackgroundfetchsuccess { get; set; }
Property Value
Oncanmakepayment
[Value("oncanmakepayment")]
public EventHandlerNonNull Oncanmakepayment { get; set; }
Property Value
Oncontentdelete
[Value("oncontentdelete")]
public EventHandlerNonNull Oncontentdelete { get; set; }
Property Value
Oncookiechange
[Value("oncookiechange")]
public EventHandlerNonNull Oncookiechange { get; set; }
Property Value
Onfetch
[Value("onfetch")]
public EventHandlerNonNull Onfetch { get; set; }
Property Value
Oninstall
[Value("oninstall")]
public EventHandlerNonNull Oninstall { get; set; }
Property Value
Onmessage
[Value("onmessage")]
public EventHandlerNonNull Onmessage { get; set; }
Property Value
Onmessageerror
[Value("onmessageerror")]
public EventHandlerNonNull Onmessageerror { get; set; }
Property Value
Onnotificationclick
[Value("onnotificationclick")]
public EventHandlerNonNull Onnotificationclick { get; set; }
Property Value
Onnotificationclose
[Value("onnotificationclose")]
public EventHandlerNonNull Onnotificationclose { get; set; }
Property Value
Onpaymentrequest
[Value("onpaymentrequest")]
public EventHandlerNonNull Onpaymentrequest { get; set; }
Property Value
Onperiodicsync
[Value("onperiodicsync")]
public EventHandlerNonNull Onperiodicsync { get; set; }
Property Value
Onpush
[Value("onpush")]
public EventHandlerNonNull Onpush { get; set; }
Property Value
Onpushsubscriptionchange
[Value("onpushsubscriptionchange")]
public EventHandlerNonNull Onpushsubscriptionchange { get; set; }
Property Value
Onsync
[Value("onsync")]
public EventHandlerNonNull Onsync { get; set; }
Property Value
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
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
undefinedafter 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