Interface NetworkState

Online status.

interface NetworkState {
    onLine: boolean;
    hasAnyListeners(): boolean;
    hasListeners(type: keyof NetworkStateEventMap): boolean;
    nextOnLine(abort?: Maybe<ReadonlyAbort>): Promise<void>;
    on<K>(type: K, handler: EventHandler<NetworkStateEventMap[K]>, options?: SignalOptions): Unsubscribe;
}

Hierarchy (view full)

Implemented by

Properties

onLine: boolean

Returns the online status of the browser.

Methods

  • Returns true if the event host has any listeners.

    Returns boolean

  • Returns a promise that resolves when the network state is next online. Rejects immediately if the given abortSignal is in an aborted state. Resolves immediately if the navigator is currently online.

    Parameters

    • Optionalabort: Maybe<ReadonlyAbort>

      If provided, rejects the returned promise when aborted.

    Returns Promise<void>