You're reading the Rask v1.0.0 guides.View source
All guides

IBattery

Charge level and charging state.

  • Wraps: Battery Status API (navigator.getBattery)
  • MDN: Battery Status API
  • Home: Rask.Core.Browser (all hosts)
  • Shape: one-shot (GetStatusAsync) + subscription (WatchAsync pushes to a callback)
  • Availability: Web/Server ⚠️ (Chromium-only) · PWA/WASM ⚠️ (Chromium-only)

GetStatusAsync() reads the current BatteryStatus (level 0.01.0, charging flag, and — where the backend reports them — charge/discharge time in seconds) once, or null where the platform doesn't expose it. WatchAsync(onChange) subscribes to level/charging changes and returns an IAsyncDisposable; dispose it on unmount. Browser support is Chromium-family only (Firefox and Safari removed or never shipped the API), so gate on a null status rather than assuming a reading.

See also