mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 08:32:52 +08:00
refactor(batterystatus): add interface for battery status object
This commit is contained in:
parent
046d17e574
commit
e776541ca0
@ -31,9 +31,9 @@ export class BatteryStatus {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch the change in battery level
|
* Watch the change in battery level
|
||||||
* @returns {Observable} Returns an observable that pushes the new battery level
|
* @returns {Observable} Returns an observable that pushes a status object
|
||||||
*/
|
*/
|
||||||
static onChange () : Observable<any> {
|
static onChange () : Observable<StatusObject> {
|
||||||
return new Observable(observer => {
|
return new Observable(observer => {
|
||||||
let callback = (status : any) => observer.next(status);
|
let callback = (status : any) => observer.next(status);
|
||||||
window.addEventListener("batterystatus", callback, false);
|
window.addEventListener("batterystatus", callback, false);
|
||||||
@ -41,4 +41,16 @@ export class BatteryStatus {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StatusObject {
|
||||||
|
/**
|
||||||
|
* The battery charge percentage
|
||||||
|
*/
|
||||||
|
level : number,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A boolean that indicates whether the device is plugged in
|
||||||
|
*/
|
||||||
|
isPlugged : boolean
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user