mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 16:52:53 +08:00
docs(battery-status): refactored example code
docs(battery-status): refactored example code
This commit is contained in:
commit
4fb73ca224
@ -1,9 +1,8 @@
|
||||
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';
|
||||
|
||||
export interface BatteryStatusResponse {
|
||||
|
||||
/**
|
||||
* The battery charge percentage
|
||||
*/
|
||||
@ -13,7 +12,6 @@ export interface BatteryStatusResponse {
|
||||
* A boolean that indicates whether the device is plugged in
|
||||
*/
|
||||
isPlugged: boolean;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -31,11 +29,9 @@ export interface BatteryStatusResponse {
|
||||
*
|
||||
*
|
||||
* // watch change in battery status
|
||||
* let subscription = this.batteryStatus.onChange().subscribe(
|
||||
* (status: BatteryStatusResponse) => {
|
||||
* const subscription = this.batteryStatus.onChange().subscribe(status => {
|
||||
* console.log(status.level, status.isPlugged);
|
||||
* }
|
||||
* );
|
||||
* });
|
||||
*
|
||||
* // stop watch
|
||||
* subscription.unsubscribe();
|
||||
@ -53,7 +49,6 @@ export interface BatteryStatusResponse {
|
||||
})
|
||||
@Injectable()
|
||||
export class BatteryStatus extends IonicNativePlugin {
|
||||
|
||||
/**
|
||||
* Watch the change in battery level
|
||||
* @returns {Observable<BatteryStatusResponse>} Returns an observable that pushes a status object
|
||||
@ -62,7 +57,9 @@ export class BatteryStatus extends IonicNativePlugin {
|
||||
eventObservable: true,
|
||||
event: 'batterystatus'
|
||||
})
|
||||
onChange(): Observable<BatteryStatusResponse> { return; }
|
||||
onChange(): Observable<BatteryStatusResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch when the battery level goes low
|
||||
@ -72,7 +69,9 @@ export class BatteryStatus extends IonicNativePlugin {
|
||||
eventObservable: true,
|
||||
event: 'batterylow'
|
||||
})
|
||||
onLow(): Observable<BatteryStatusResponse> { return; }
|
||||
onLow(): Observable<BatteryStatusResponse> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Watch when the battery level goes to critial
|
||||
@ -82,6 +81,7 @@ export class BatteryStatus extends IonicNativePlugin {
|
||||
eventObservable: true,
|
||||
event: 'batterycritical'
|
||||
})
|
||||
onCritical(): Observable<BatteryStatusResponse> { return; }
|
||||
|
||||
onCritical(): Observable<BatteryStatusResponse> {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user