ServiceWorkerContainer

The ServiceWorkerContainer interface of the Service Worker API provides an object representing the service worker as an overall unit in the network ecosystem, including facilities to register, unregister and update service workers, and access the state of service workers and their registrations. Available only in secure contexts.

MDN Reference

Properties

Link copied to clipboard

The controller read-only property of the ServiceWorkerContainer interface returns a activated (the same object returned by null if the request is a force refresh (Shift + refresh) or if there is no active worker.

Link copied to clipboard

The ready read-only property of the ServiceWorkerContainer interface provides a way of delaying code execution until a service worker is active.

Functions

Link copied to clipboard
Link copied to clipboard
suspend fun getRegistration(clientURL: String = definedExternally): ServiceWorkerRegistration?

The getRegistration() method of the client URL.

Link copied to clipboard
Link copied to clipboard

The getRegistrations() method of the ServiceWorkerContainer, in an array.

Link copied to clipboard
suspend fun register(scriptURL: String, options: RegistrationOptions = definedExternally): ServiceWorkerRegistration

The register() method of the ServiceWorkerContainer interface creates or updates a ServiceWorkerRegistration for the given scope.

suspend fun register(scriptURL: URL, options: RegistrationOptions = definedExternally): ServiceWorkerRegistration
Link copied to clipboard
fun registerAsync(scriptURL: String, options: RegistrationOptions = definedExternally): Promise<ServiceWorkerRegistration>
fun registerAsync(scriptURL: URL, options: RegistrationOptions = definedExternally): Promise<ServiceWorkerRegistration>
Link copied to clipboard

The startMessages() method of the ServiceWorkerContainer interface explicitly starts the flow of messages being dispatched from a service worker to pages under its control (e.g., sent via Client.postMessage()).

Link copied to clipboard