Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

ServiceWorker

This ServiceWorker API interface provides a reference to a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object. Available only in secure contexts.

interface ServiceWorker extends EventTarget, AbstractWorker {
onstatechange: ((this: ServiceWorker, ev: Event) => any) | null;
readonly scriptURL: string;
readonly state: ServiceWorkerState;
addEventListener<K extends keyof ServiceWorkerEventMap>(
type: K,
listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void;
postMessage(message: any, transfer: Transferable[]): void;
postMessage(message: any, options?: StructuredSerializeOptions): void;
removeEventListener<K extends keyof ServiceWorkerEventMap>(
type: K,
listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void;
}
var ServiceWorker: {
prototype: ServiceWorker;
new (): ServiceWorker;
}
;

§Extends

§Properties

§
onstatechange: ((this: ServiceWorker, ev: Event) => any) | null
[src]
§
readonly scriptURL: string
[src]

§Methods

§
addEventListener<K extends keyof ServiceWorkerEventMap>(
type: K,
listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
[src]
§
postMessage(message: any, transfer: Transferable[]): void
[src]
§
postMessage(message: any, options?: StructuredSerializeOptions): void
[src]
§
removeEventListener<K extends keyof ServiceWorkerEventMap>(
type: K,
listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
[src]
§
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void
[src]