This API provides an implementation of the Battery Status Events API.
var subscription = BatteryStatus.onChange().subscribe(status => {
console.log(status.level, status.isPlugged);
});
...
subscription.unsubscribe();
var subscription = window.BatteryStatus.onChange().subscribe((status) => {
console.log(status.level, status.isPlugged);
});
...
subscription.unsubscribe();
var subscription = window.BatteryStatus.onChange().subscribe((status) => {
console.log(status.level, status.isPlugged);
});
...
subscription.unsubscribe();
var subscription = (<any>window).BatteryStatus.onChange().subscribe((status) => {
console.log(status.level, status.isPlugged);
});
...
subscription.unsubscribe();
var subscription = window.BatteryStatus.onChange().subscribe((status) => {
console.log(status.level, status.isPlugged);
});
...
subscription.unsubscribe();
onBatteryStatus(): Observable<ResultOnBatteryStatus>
Fires when the battery charge percentage changes by at least 1 percent, or when the device is plugged in or unplugged.
onBatteryLow(): Observable<ResultOnBatteryStatus>
Fires when the battery charge percentage reaches the low charge threshold. This threshold value is device-specific.
onBatteryCritical(): Observable<ResultOnBatteryStatus>
Fires when the battery charge percentage reaches the critical charge threshold. This threshold value is device-specific.
interface ResultOnBatteryStatus{ // The battery charge percentage (0-100) level: number; // A boolean that indicates whether the device is plugged in isPlugged: boolean; }