ServiceWorkerContainer
The ServiceWorkerContainer interface of the ServiceWorker 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.
Documentation ServiceWorkerContainer by Mozilla Contributors, licensed under CC-BY-SA 2.5.
Instance Members
controller: ServiceWorkerReturns a ServiceWorker object if its state is activated (the same object returned by ServiceWorkerRegistration.active). This property returns null during a force-refresh request (Shift + refresh) or if there is no active worker.
Provides a way of delaying code execution until a service worker is active. It returns a Promise that will never reject, and which waits indefinitely until the ServiceWorkerRegistration associated with the current page has an ServiceWorkerRegistration.active worker. Once that condition is met, it resolves with the ServiceWorkerRegistration.
oncontrollerchange: haxe.FunctionFired whenever a controllerchange event occurs — when the document's associated ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active worker.
onerror: haxe.FunctionFired whenever an error event occurs in the associated service workers.
onmessage: haxe.FunctionFired whenever a message event occurs — when incoming messages are received to the ServiceWorkerContainer object (e.g. via a MessagePort.postMessage() call.)
register(scriptURL: String, ?options: Null<RegistrationOptions>): js.lib.Promise<ServiceWorkerRegistration>| Name | Type | Default |
|---|---|---|
scriptURL |
String | |
options |
Null<RegistrationOptions> | (optional) |
| Returns |
|---|
| js.lib.Promise<ServiceWorkerRegistration> |
getRegistration(?documentURL: String = ""): js.lib.Promise<Dynamic>Gets a ServiceWorkerRegistration object whose scope matches the provided document URL. If the method can't return a ServiceWorkerRegistration, it returns a Promise.
| Name | Type | Default |
|---|---|---|
documentURL |
String | "" |
| Returns |
|---|
| js.lib.Promise<Dynamic> |
getRegistrations(): js.lib.Promise<Array<ServiceWorkerRegistration>>Returns all ServiceWorkerRegistration objects associated with a ServiceWorkerContainer in an array. If the method can't return ServiceWorkerRegistration objects, it returns a Promise.
| Returns |
|---|
| js.lib.Promise<Array<ServiceWorkerRegistration>> |