ServiceWorkerGlobalScope class

The interface of the Service Worker API represents the global execution context of a service worker. 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.onfetch or ServiceWorkerGlobalScope.onmessage. Additionally, synchronous requests are not allowed from within a service worker — only asynchronous requests, like those initiated via the fetch() method, can be used. This interface inherits from the WorkerGlobalScope interface, and its parent EventTarget.

EventTarget

WorkerGlobalScope

ServiceWorkerGlobalScope

Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

ServiceWorkerGlobalScope()
factory

Properties

caches CacheStorage

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
clients Clients

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

no setter
cookieStore CookieStore

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

no setter
crossOriginIsolated bool

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
crypto Crypto

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
fonts FontFaceSet

Available on FontFaceSource, provided by the PropsFontFaceSource extension

no setter
hashCode int
The hash code for this object.
no setterinherited
indexedDB IDBFactory

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
isSecureContext bool

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
location WorkerLocation

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

no setter

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

no setter
onactivate EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onbackgroundfetchabort EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onbackgroundfetchclick EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onbackgroundfetchfail EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onbackgroundfetchsuccess EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
oncanmakepayment EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
oncontentdelete EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
oncookiechange EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onerror OnErrorEventHandlerNonNull?

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

getter/setter pair
onfetch EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
oninstall EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onlanguagechange EventHandlerNonNull<Event>?

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

getter/setter pair
onmessage EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onmessageerror EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onnotificationclick EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onnotificationclose EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onoffline EventHandlerNonNull<Event>?

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

getter/setter pair
ononline EventHandlerNonNull<Event>?

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

getter/setter pair
onpaymentrequest EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onperiodicsync EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onpush EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onpushsubscriptionchange EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onrejectionhandled EventHandlerNonNull<Event>?

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

getter/setter pair
onsync EventHandlerNonNull<Event>?

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

getter/setter pair
onunhandledrejection EventHandlerNonNull<Event>?

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

getter/setter pair
origin String

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
performance Performance

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
registration ServiceWorkerRegistration

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scheduler Scheduler

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter
self WorkerGlobalScope

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

no setter
serviceWorker ServiceWorker

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

no setter
trustedTypes TrustedTypePolicyFactory

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

no setter

Methods

addEventListener(String type, EventListener? callback, [dynamic options]) → void

Available on EventTarget, provided by the PropsEventTarget extension

atob(String data) String

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

btoa(String data) String

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

clearInterval([int? id = 0]) → void

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

clearTimeout([int? id = 0]) → void

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

createImageBitmap(dynamic image, [int? sx, int? sy, int? sw, int? sh, ImageBitmapOptions? options]) Future<ImageBitmap>

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

dispatchEvent(Event event) bool

Available on EventTarget, provided by the PropsEventTarget extension

fetch(dynamic input, [RequestInit? init]) Future<Response>

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

importScripts([String? urls1, String? urls2, String? urls3]) → void

Available on WorkerGlobalScope, provided by the PropsWorkerGlobalScope extension

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queueMicrotask(VoidFunction callback) → void

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

removeEventListener(String type, EventListener? callback, [dynamic options]) → void

Available on EventTarget, provided by the PropsEventTarget extension

reportError(dynamic e) → void

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

setInterval(dynamic handler, [int? timeout = 0, dynamic arguments1, dynamic arguments2, dynamic arguments3]) int

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

setTimeout(dynamic handler, [int? timeout = 0, dynamic arguments1, dynamic arguments2, dynamic arguments3]) int

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

skipWaiting() Future<void>

Available on ServiceWorkerGlobalScope, provided by the PropsServiceWorkerGlobalScope extension

structuredClone(dynamic value, [StructuredSerializeOptions? options]) → dynamic

Available on WindowOrWorkerGlobalScope, provided by the PropsWindowOrWorkerGlobalScope extension

toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited