Summary
Battery API listeners can survive component disposal, and Angular's battery service never removes its listeners.
Evidence
React, Vue, Svelte, and Solid attach listeners after asynchronous navigator.getBattery() resolution without consistently guarding against unmount before the promise settles. Angular attaches anonymous listener functions and cannot remove them during unregister()/ngOnDestroy(); repeated initialization accumulates listeners.
Affected implementations include each adapter's useAskableBatterySource and Angular's askable-battery-source.service.ts.
Proposed fix
- Track disposal/generation around asynchronous battery initialization.
- Do not update or attach if resolution occurs after disposal.
- Keep stable named listener references.
- Remove every listener and clear retained battery state during cleanup.
Acceptance criteria
Summary
Battery API listeners can survive component disposal, and Angular's battery service never removes its listeners.
Evidence
React, Vue, Svelte, and Solid attach listeners after asynchronous
navigator.getBattery()resolution without consistently guarding against unmount before the promise settles. Angular attaches anonymous listener functions and cannot remove them duringunregister()/ngOnDestroy(); repeated initialization accumulates listeners.Affected implementations include each adapter's
useAskableBatterySourceand Angular'saskable-battery-source.service.ts.Proposed fix
Acceptance criteria
getBattery()after unmount attaches no listeners and performs no state update