Skip to content

onOffline

The onOffline function adds a listener for the browser's offline event.

Syntax

typescript
onOffline(listener: () => void): void;

Parameters

NameTypeDescription
listener() => voidFunction called when going offline

Returns

NameTypeDescription
voidDoes not return a value

Examples

typescript
onOffline(() => {
  alert("You are offline!");
});

Notes

  • Useful for detecting loss of connection and adapting the interface.

References

Released under the MIT License.