ServiceWorkerContainer
package js.html
extends EventTarget
Available on js
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.
See also:
Variables
read onlycontroller:ServiceWorker
Returns 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.
oncontrollerchange:Function
Fired whenever a controllerchange
event occurs — when the document's associated ServiceWorkerRegistration
acquires a new ServiceWorkerRegistration.active
worker.
onerror:Function
Fired whenever an error
event occurs in the associated service workers.
onmessage:Function
Fired whenever a message
event occurs — when incoming messages are received to the ServiceWorkerContainer
object (e.g. via a MessagePort.postMessage()
call.)
read onlyready:Promise<ServiceWorkerRegistration>
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
.
Methods
getRegistration(documentURL:String = ""):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
.
getRegistrations():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
.
register(scriptURL:String, ?options:Null<RegistrationOptions>):Promise<ServiceWorkerRegistration>
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/js/html/ServiceWorkerContainer.html