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. Available only in secure contexts.
interface ServiceWorkerContainer extends EventTarget {
readonly controller: ServiceWorker | null;
oncontrollerchange: ((this: ServiceWorkerContainer, ev: Event) => any) | null;
onmessage: ((this: ServiceWorkerContainer, ev: MessageEvent) => any) | null;
onmessageerror: ((this: ServiceWorkerContainer, ev: MessageEvent) => any) | null;
readonly ready: Promise<ServiceWorkerRegistration>;
addEventListener<K extends keyof ServiceWorkerContainerEventMap>(
type: K,
listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;getRegistration(clientURL?: string | URL): Promise<ServiceWorkerRegistration | undefined>;
getRegistrations(): Promise<ReadonlyArray<ServiceWorkerRegistration>>;
register(scriptURL: string | URL, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>;
removeEventListener<K extends keyof ServiceWorkerContainerEventMap>(
type: K,
listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;startMessages(): void;
}var ServiceWorkerContainer: {
prototype: ServiceWorkerContainer;
new (): ServiceWorkerContainer;
};§Extends
§Properties
§
readonly controller: ServiceWorker | null
[src]§
oncontrollerchange: ((this: ServiceWorkerContainer, ev: Event) => any) | null
[src]§
onmessage: ((this: ServiceWorkerContainer, ev: MessageEvent) => any) | null
[src]§
onmessageerror: ((this: ServiceWorkerContainer, ev: MessageEvent) => any) | null
[src]§
readonly ready: Promise<ServiceWorkerRegistration>
[src]§Methods
§
addEventListener<K extends keyof ServiceWorkerContainerEventMap>(
[src]type: K,
listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void§
addEventListener(
[src]type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void§
getRegistration(clientURL?: string | URL): Promise<ServiceWorkerRegistration | undefined>
[src]§
getRegistrations(): Promise<ReadonlyArray<ServiceWorkerRegistration>>
[src]§
register(scriptURL: string | URL, options?: RegistrationOptions): Promise<ServiceWorkerRegistration>
[src]§
removeEventListener<K extends keyof ServiceWorkerContainerEventMap>(
[src]type: K,
listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void§
removeEventListener(
[src]type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void