ServiceWorker class

Represents a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same ServiceWorker object.

Implemented types

Properties

hashCode → int
The hash code for this object.
no setterinherited
id → String?
no setter
on → Events
This is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
no setteroverride
onError → Stream<ErrorEvent>
An event handler fired whenever an error event occurs in the associated service workers.
no setteroverride
onMessage → Stream<MessageEvent>
An event handler fired whenever a message event occurs — when incoming messages are received to the ServiceWorkerContainer object (e.g. via a MessagePort.postMessage() call.)
no setteroverride
onStateChange → Stream<Event>
An EventListener property called whenever an event of type statechange is fired; it is basically fired anytime the ServiceWorker.state changes.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scriptURL → String?
Returns the ServiceWorker serialized script URL defined as part of ServiceWorkerRegistration. The URL must be on the same origin as the document that registers the ServiceWorker.
no setter
state → String?
Returns the state of the service worker. It returns one of the following values: installing, installed, activating, activated, or redundant.
no setter

Methods

addEventListener(String type, EventListener? listener, [bool? useCapture]) → void
override
dispatchEvent(Event event) → bool
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
postMessage(dynamic message, [List? transfer]) → void
override
removeEventListener(String type, EventListener? listener, [bool? useCapture]) → void
override
terminate() → void
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited