Repository
public class |source

BatteryStatus

Extends:

Component → BatteryStatus

Component to monitor battery status changes

Member Summary

Private Members
private
private

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
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

chargingtimechange event handler Fires a chargingtimechange event

private

levelchange event handler Fires a levelchange event

private

onLevelChange(event: *)

dischargingtimechange event handler Fires a dischargingtimechange event

Inherited Summary

From class Component
public
public
public

events: *

public

id: *

public

name: *

private

_nexts: *[]

private
public
public

chain(component: Component)

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 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 the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server.

public

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 the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism

Private Members

private _batteryAvailable: * source

private _manager: * source

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 off() source

Deactivate the component

Override:

Component#off

public on() source

Activate the component A call to this method calls the setup method if it has not been run yet

Override:

Component#on

public 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#setup

Private Methods

private onBatteryManager(manager: BatteryManager) source

battery API promise callback Adds event listeners on the battery manager

Params:

NameTypeAttributeDescription
managerBatteryManager

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:

NameTypeAttributeDescription
event*

private onChargingTimeChange(event: *) source

chargingtimechange event handler Fires a chargingtimechange event

Params:

NameTypeAttributeDescription
event*

private onDischargingTimeChange(event: *) source

levelchange event handler Fires a levelchange event

Params:

NameTypeAttributeDescription
event*

private onLevelChange(event: *) source

dischargingtimechange event handler Fires a dischargingtimechange event

Params:

NameTypeAttributeDescription
event*