Battery Status

This API provides an implementation of the Battery Status Events API.

Usage
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();

Classes

BatteryStatus

onBatteryStatus
onBatteryStatus(): Observable<ResultOnBatteryStatus>

Fires when the battery charge percentage changes by at least 1 percent, or when the device is plugged in or unplugged.

RETURN
returns: Observable<ResultOnBatteryStatus>
onBatteryLow
onBatteryLow(): Observable<ResultOnBatteryStatus>

Fires when the battery charge percentage reaches the low charge threshold. This threshold value is device-specific.

RETURN
returns: Observable<ResultOnBatteryStatus>
onBatteryCritical
onBatteryCritical(): Observable<ResultOnBatteryStatus>

Fires when the battery charge percentage reaches the critical charge threshold. This threshold value is device-specific.

RETURN
returns: Observable<ResultOnBatteryStatus>

Interfaces

ResultOnBatteryStatus
interface ResultOnBatteryStatus{
    // The battery charge percentage (0-100)
    level: number;
    // A boolean that indicates whether the device is plugged in
    isPlugged: boolean;
}