worker library
The Worker global scope of the ServiceWorker.
Classes
- Body
- Cache
- Represents the storage for Request / Response object pairs that are cached as part of the ServiceWorker life cycle.
- CacheOptions
- Type definitions for service_worker_api 0.0 Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API Definitions by: Tristan Caron github.com/tristancaron Definitions: https://github.com/borisyankov/DefinitelyTyped TypeScript Version: 2.1
- CacheStorage
- Represents the storage for Cache objects. It provides a master directory of all the named caches that a ServiceWorker can access and maintains a mapping of string names to corresponding Cache objects.
- ErrorEvent
- Event
- ExtendableEvent
- Extends the lifetime of the install and activate events dispatched on the ServiceWorkerGlobalScope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched to the ServiceWorker until it upgrades database schemas, deletes outdated cache entries, etc.
- ExtendableMessageEvent
- The ExtendableMessageEvent interface of the ServiceWorker API represents the event object of a message event fired on a service worker (when a channel message is received on the ServiceWorkerGlobalScope from another context) — extends the lifetime of such events.
- FetchEvent
- The parameter passed into the ServiceWorkerGlobalScope.onfetch handler, FetchEvent represents a fetch action that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker. It contains information about the request and resulting response, and provides the FetchEvent.respondWith() method, which allows us to provide an arbitrary response back to the controlled page.
- Headers
- InstallEvent
- The parameter passed into the oninstall handler, the InstallEvent interface represents an install action that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, it ensures that functional events such as FetchEvent are not dispatched during installation.
- MessageEvent
- Notification
- The Notification interface of the Notifications API is used to configure and display desktop notifications to the user.
- NotificationEvent
- The parameter passed into the onnotificationclick handler, the NotificationEvent interface represents a notification click event that is dispatched on the ServiceWorkerGlobalScope of a ServiceWorker.
- PushEvent
- The PushEvent interface of the Push API represents a push message that has been received. This event is sent to the global scope of a ServiceWorker. It contains the information sent from an application server to a PushSubscription.
- PushManager
- The PushManager interface provides a way to receive notifications from third-party servers as well as request URLs for push notifications. This interface has replaced functionality offered by the obsolete PushRegistrationManager.
- PushMessageData
- The PushMessageData interface of the Push API provides methods which let you retrieve the push data sent by a server in various formats.
- PushSubscription
- The PushSubscription interface provides a subcription's URL endpoint and subscription ID.
- PushSubscriptionKeys
- Key values that may be stored in a PushSubscription.
- PushSubscriptionOptions
- Object containing optional subscribe parameters.
- Request
- RequestInit
- Response
- ServiceWorker
- Represents a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same ServiceWorker object.
- ServiceWorkerClient
- Represents the scope of a service worker client. A service worker client is either a document in a browser context or a SharedWorker, which is controlled by an active worker.
- ServiceWorkerClients
- Represents a container for a list of Client objects; the main way to access the active service worker clients at the current origin.
- ServiceWorkerClientsMatchOptions
- ServiceWorkerGlobalScope
- A ServiceWorkerGlobalScope object represents the global execution context of a service worker.
- ServiceWorkerRegisterOptions
- ServiceWorkerRegistration
- Represents a service worker registration.
- ShowNotificationAction
- ShowNotificationOptions
- WindowClient
- WorkerLocation
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
- 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
Functions
-
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 -
skipWaiting(
) → Future< void> - Allows the current service worker registration to progress from waiting to active state while service worker clients are using it.