From e776541ca070cb68558c13b724cebb0237f1f3ab Mon Sep 17 00:00:00 2001 From: Ibrahim Hadeed Date: Thu, 10 Mar 2016 15:17:51 -0500 Subject: [PATCH] refactor(batterystatus): add interface for battery status object --- src/plugins/batterystatus.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/batterystatus.ts b/src/plugins/batterystatus.ts index ea739af4e..81c393977 100644 --- a/src/plugins/batterystatus.ts +++ b/src/plugins/batterystatus.ts @@ -31,9 +31,9 @@ export class BatteryStatus { /** * 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 { + static onChange () : Observable { return new Observable(observer => { let callback = (status : any) => observer.next(status); 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 } \ No newline at end of file