Stress
Start from API_LEVEL
2.0
. Please refer to API_LEVEL.
Stress Sensor.
info
permission code: data:user.hd.stress
Methods
getCurrent
Get the current pressure measurement
getCurrent(): Result
Result
Property | Type | Description | API_LEVEL |
---|---|---|---|
value | number | Stress measurement values | 2.0 |
time | number | Time to obtain the measured value | 2.0 |
onChange
Register a callback function to listen for stress measurement change events
onChange(callback: () => void): void
offChange
Cancel a callback function to listen for stress measurement change events
offChange(callback: () => void): void
Example
import { Stress } from '@zos/sensor'
const stress = new Stress()
const { value } = stress.getCurrent()
const callback = () => {
console.log(stress.getCurrent())
}
stress.onChange(callback)
// When not needed for use
stress.offChange(callback)