docs(battery-status): refactored example code

docs(battery-status): refactored example code
This commit is contained in:
Daniel Sogl 2018-03-16 16:56:33 +01:00 committed by GitHub
commit 4fb73ca224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,8 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Cordova, Plugin, IonicNativePlugin } from '@ionic-native/core'; import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
export interface BatteryStatusResponse { export interface BatteryStatusResponse {
/** /**
* The battery charge percentage * The battery charge percentage
*/ */
@ -13,7 +12,6 @@ export interface BatteryStatusResponse {
* A boolean that indicates whether the device is plugged in * A boolean that indicates whether the device is plugged in
*/ */
isPlugged: boolean; isPlugged: boolean;
} }
/** /**
@ -31,11 +29,9 @@ export interface BatteryStatusResponse {
* *
* *
* // watch change in battery status * // watch change in battery status
* let subscription = this.batteryStatus.onChange().subscribe( * const subscription = this.batteryStatus.onChange().subscribe(status => {
* (status: BatteryStatusResponse) => {
* console.log(status.level, status.isPlugged); * console.log(status.level, status.isPlugged);
* } * });
* );
* *
* // stop watch * // stop watch
* subscription.unsubscribe(); * subscription.unsubscribe();
@ -53,7 +49,6 @@ export interface BatteryStatusResponse {
}) })
@Injectable() @Injectable()
export class BatteryStatus extends IonicNativePlugin { export class BatteryStatus extends IonicNativePlugin {
/** /**
* Watch the change in battery level * Watch the change in battery level
* @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object * @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
@ -62,7 +57,9 @@ export class BatteryStatus extends IonicNativePlugin {
eventObservable: true, eventObservable: true,
event: 'batterystatus' event: 'batterystatus'
}) })
onChange(): Observable<BatteryStatusResponse> { return; } onChange(): Observable<BatteryStatusResponse> {
return;
}
/** /**
* Watch when the battery level goes low * Watch when the battery level goes low
@ -72,7 +69,9 @@ export class BatteryStatus extends IonicNativePlugin {
eventObservable: true, eventObservable: true,
event: 'batterylow' event: 'batterylow'
}) })
onLow(): Observable<BatteryStatusResponse> { return; } onLow(): Observable<BatteryStatusResponse> {
return;
}
/** /**
* Watch when the battery level goes to critial * Watch when the battery level goes to critial
@ -82,6 +81,7 @@ export class BatteryStatus extends IonicNativePlugin {
eventObservable: true, eventObservable: true,
event: 'batterycritical' event: 'batterycritical'
}) })
onCritical(): Observable<BatteryStatusResponse> { return; } onCritical(): Observable<BatteryStatusResponse> {
return;
}
} }