ServiceWorkerGlobalScope class
A ServiceWorkerGlobalScope object represents the global execution context of a service worker.
Properties
- caches → CacheStorage
-
Contains the CacheStorage object associated with the service worker.
no setter
- clients → ServiceWorkerClients
-
Contains the Clients object associated with the service worker.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- indexedDB → IdbFactory?
-
Returns the indexedDB in the current scope.
no setter
- location → WorkerLocation
-
no setter
-
onActivate
→ Stream<
ExtendableEvent> -
An event handler fired whenever an activate event occurs — when a
ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active
worker.
no setter
-
onFetch
→ Stream<
FetchEvent> -
An event handler fired whenever a fetch event occurs — when a fetch()
is called.
no setter
-
onInstall
→ Stream<
InstallEvent> -
An event handler fired whenever an install event occurs — when a
ServiceWorkerRegistration acquires a new
ServiceWorkerRegistration.installing worker.
no setter
-
onMessage
→ Stream<
ExtendableMessageEvent> -
An event handler fired whenever a message event occurs — when incoming
messages are received. Controlled pages can use the
MessagePort.postMessage() method to send messages to service workers.
The service worker can optionally send a response back via the
MessagePort exposed in event.data.port, corresponding to the controlled
page.
onmessage
is actually fired withExtendableMessageEvent
, but since we are merging the interface intoWindow
, we should make sure it's compatible withwindow.onmessage
onmessage: (messageevent: ExtendableMessageEvent) => void;no setter -
onNotificationClick
→ Stream<
NotificationEvent> -
An event handler fired whenever a notificationclick event occurs — when
a user clicks on a displayed notification.
no setter
-
onPush
→ Stream<
PushEvent> -
An event handler fired whenever a push event occurs — when a server
push notification is received.
no setter
-
onPushSubscriptionChange
→ Stream<
PushEvent> -
An event handler fired whenever a pushsubscriptionchange event occurs —
when a push subscription has been invalidated, or is about to be
invalidated (e.g. when a push service sets an expiration time).
no setter
- registration → ServiceWorkerRegistration
-
Contains the ServiceWorkerRegistration object that represents the
service worker's registration.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addEventListener<
K> (String type, dynamic listener(K event), [bool? useCapture]) → void - Attach an event listener.
-
fetch(
dynamic request, [RequestInit? requestInit]) → Future< Response> -
Fetches the
request
and returns the Response -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
skipWaiting(
) → Future< void> - Allows the current service worker registration to progress from waiting to active state while service worker clients are using it.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- globalScope → ServiceWorkerGlobalScope
-
API entry point for ServiceWorkers.
final
- self → ServiceWorkerGlobalScope
-
As ServiceWorkerGlobalScope has an instance-level self defined, this
static value will be removed in the next release.
final