Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / dom/src/public-api / onNetwork

Function: onNetwork()

onNetwork(): Stream<NetworkState>

Defined in: projects/libraries/streamix/dom/src/lib/streams/onNetwork.ts:33

Creates a reactive stream that emits network connectivity changes.

This stream combines:

  • online / offline events
  • Network Information API (when available)

Behavior:

  • Emits an initial snapshot on start.
  • Emits whenever connectivity or connection quality changes.
  • Starts listening on first subscriber.
  • Stops listening when the last subscriber unsubscribes.
  • Gracefully degrades when Network Information API is unavailable.
  • Safe to import and subscribe in SSR (no-op).
  • Fully compatible with async iteration.

Returns

Stream<NetworkState>

Released under the GNU AGPL v3 or later.