-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explore a high-level API #52
Comments
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: 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"));
}
}); |
@beaufortfrancois thanks! This is on our TPAC agenda w3c/devicesensors-wg#56 |
Here’s a rather hilarious use case that would be enabled by such a high-level API: Die With Me, “[t]he chat app you can only use when you have less than 5% battery”. |
via https://bugs.chromium.org/p/chromium/issues/detail?id=661792#c49
See also #25 (comment)
The text was updated successfully, but these errors were encountered: