Re: [battery] Explore a high-level API (#52)

For info, I've played a bit with this high-level API and created a quick demo at https://high-level-battery-api.glitch.me/

You can look at the source code at https://glitch.com/edit/#!/high-level-battery-api?path=index.js

It looks like this:
```js
const battery = await navigator.getBattery();

battery.addEventListener("levelchange", () => {
  if (battery.level < 0.1) {
    battery.dispatchEvent(new Event("lowpower"));
  } else if (battery.level === 1) {
    battery.dispatchEvent(new Event("fullpower"));
  }
});
```

-- 
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at https://github.com/w3c/battery/issues/52#issuecomment-1173781287 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 4 July 2022 12:47:44 UTC