Skip to content

@epikodelabs/streamix


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

Function: onBattery()

onBattery(): Stream<BatteryState>

Defined in: projects/libraries/streamix/dom/src/lib/streams/onBattery.ts:28

Creates a reactive stream that emits battery state changes.

Uses the Battery Status API when available.

Behavior:

  • Emits an initial battery snapshot on start.
  • Emits on charging, level, and time changes.
  • Starts listening on first subscriber.
  • Stops listening when the last subscriber unsubscribes.
  • Safe to import and subscribe in SSR (no-op).
  • Fully compatible with async iteration.

Returns

Stream<BatteryState>

Released under the GNU AGPL v3 or later.