Calorie
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Calorie Sensor.
info
permission code: data:user.hd.calorie
Methods
getCurrent
Get the current calorie consumption in kcal
getCurrent(): number
getTarget
Get the target calorie consumption in kcal
getTarget(): number
onChange
Register the calories change event callback function
onChange(callback: () => void): void
offChange
Cancel the calories change event callback function
offChange(callback: () => void): void
Example
import { Calorie } from '@zos/sensor'
const calorie = new Calorie()
const current = calorie.getCurrent()
const target = calorie.getTarget()
const callback = () => {
console.log(calorie.getCurrent())
}
calorie.onChange(callback)
// When not needed for use
calorie.offChange(callback)