AngularTS
    Preparing search index...

    Interface ServiceWorkerService

    Injectable service-worker lifecycle and messaging facade.

    interface ServiceWorkerService {
        controller: ServiceWorker | null;
        registration: ServiceWorkerRegistration | null;
        registrationState: ServiceWorkerRegistrationState;
        status:
            | "error"
            | "unsupported"
            | "idle"
            | "registering"
            | "registered"
            | "ready"
            | "updating"
            | "unregistered";
        supported: boolean;
        updateState: ServiceWorkerUpdateState;
        onControllerChange(
            callback: (controller: ServiceWorker | null) => void,
        ): () => void;
        onMessage<TData = unknown>(
            callback: (event: ServiceWorkerMessageEvent<TData>) => void,
        ): () => void;
        onUpdate(callback: (state: ServiceWorkerUpdateState) => void): () => void;
        post(message: unknown, options?: ServiceWorkerPostOptions): Promise<void>;
        ready(): Promise<ServiceWorkerRegistration>;
        register(
            scriptOrOptions?: string | URL | RegistrationOptions,
            options?: RegistrationOptions,
        ): Promise<ServiceWorkerRegistration>;
        request<TResponse = unknown>(
            message: unknown,
            options?: ServiceWorkerRequestOptions,
        ): Promise<TResponse>;
        unregister(): Promise<boolean>;
        update(): Promise<ServiceWorkerRegistration>;
    }
    Index

    Properties

    controller: ServiceWorker | null

    Current native controller, if the page is controlled.

    registration: ServiceWorkerRegistration | null

    Latest known native registration.

    registrationState: ServiceWorkerRegistrationState

    Template-friendly registration snapshot.

    status:
        | "error"
        | "unsupported"
        | "idle"
        | "registering"
        | "registered"
        | "ready"
        | "updating"
        | "unregistered"

    Template-facing lifecycle status for the latest service-worker operation.

    supported: boolean

    Support flag for templates and guards.

    Template-friendly update snapshot.

    Methods

    • Subscribe to controller-change notifications.

      Parameters

      • callback: (controller: ServiceWorker | null) => void

      Returns () => void

    post

    • Resolve when the browser reports an active ready registration.

      Returns Promise<ServiceWorkerRegistration>

    • Register the configured script or an explicit script URL.

      Parameters

      • OptionalscriptOrOptions: string | URL | RegistrationOptions
      • Optionaloptions: RegistrationOptions

      Returns Promise<ServiceWorkerRegistration>

    • Unregister the latest known registration.

      Returns Promise<boolean>

    • Ask the latest known registration to check for an updated worker.

      Returns Promise<ServiceWorkerRegistration>