import BatteryStatus from '@mobilizing/library/js/Mobilizing/misc/BatteryStatus.js'
Member Summary
Private Members | ||
private | ||
private | _manager: * |
Method Summary
Public Methods | ||
public | Get the time remaining until the battery is fully charge The component needs to be activated before using this method | |
public | Get the time remaining until the battery is completely discharged The component needs to be activated before using this method | |
public | Get the battery's charge level The component needs to be activated before using this method | |
public | Check if the battery is currently charging The component needs to be activated before using this method | |
public | off() | |
public | on() | |
public | setup() |
Private Methods | ||
private | onBatteryManager(manager: BatteryManager) battery API promise callback Adds event listeners on the battery manager | |
private | onChargingChange(event: *) chargingchange event handler Fires a chargingchange event | |
private | onChargingTimeChange(event: *) chargingtimechange event handler Fires a chargingtimechange event | |
private | onDischargingTimeChange(event: *) levelchange event handler Fires a levelchange event | |
private | onLevelChange(event: *) dischargingtimechange event handler Fires a dischargingtimechange event |
Inherited Summary
From class Component | ||
public | ||
public | context: * | |
public | events: * | |
public | id: * | |
public | name: * | |
private | _nexts: *[] | |
private | ||
public | byPass() | |
public | Adds a component to this chained component array | |
public | Returns the array of attached children components | |
public | off() Deactivate the component | |
public | on() Activate the component A call to this method calls the setup method if it has not been run yet | |
public | Run code after the update of all components is run This empty method is usually overriden to perform post-update actions for the component It is called periodically by an internal Mobilizing mechanism | |
public | preLoad() preLoad the component This empty method is usually overriden to perform preLoad actions for the component. | |
public | Run code before the update of all components is run This empty method is usually overriden to perform pre-update actions for the component It is called once per component by an internal Mobilizing mechanism | |
public | prepare() prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server. | |
public | setup() Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly | |
public | update() Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism |
Public Methods
public getChargingTime(): Number source
Get the time remaining until the battery is fully charge The component needs to be activated before using this method
Return:
Number | The remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged |
public getDischargingTime(): Number source
Get the time remaining until the battery is completely discharged The component needs to be activated before using this method
Return:
Number | The remaining time in seconds until the battery is completely discharged and the system will suspend |
public getLevel(): Number source
Get the battery's charge level The component needs to be activated before using this method
Return:
Number | The charge level on a scale from 0.0 to 1.0 |
public isCharging(): Boolean source
Check if the battery is currently charging The component needs to be activated before using this method
Return:
Boolean | True if charging, false otherwise |
public on() source
Activate the component A call to this method calls the setup method if it has not been run yet
Override:
Component#onpublic setup() source
Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly
Override:
Component#setupPrivate Methods
private onBatteryManager(manager: BatteryManager) source
battery API promise callback Adds event listeners on the battery manager
Params:
Name | Type | Attribute | Description |
manager | BatteryManager | A BatteryManager (see https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager) |
private onChargingChange(event: *) source
chargingchange event handler Fires a chargingchange event
Params:
Name | Type | Attribute | Description |
event | * |
private onChargingTimeChange(event: *) source
chargingtimechange event handler Fires a chargingtimechange event
Params:
Name | Type | Attribute | Description |
event | * |
private onDischargingTimeChange(event: *) source
levelchange event handler Fires a levelchange event
Params:
Name | Type | Attribute | Description |
event | * |
private onLevelChange(event: *) source
dischargingtimechange event handler Fires a dischargingtimechange event
Params:
Name | Type | Attribute | Description |
event | * |