Skip to main content
Version: v2

Step

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Step Sensor.

info

permission code: data:user.hd.step

Methods

getCurrent

Get the current step count

getCurrent(): number

getTarget

Get step goal

getTarget(): number

onChange

Register the step change event callback function

onChange(callback: () => void): void

offChange

Cancel the step change event callback function

offChange(callback: () => void): void

Example

import { Step } from '@zos/sensor'

const step = new Step()
const current = step.getCurrent()
const target = step.getTarget()
const callback = () => {
console.log(step.getCurrent())
}

step.onChange(callback)

// When not needed for use
step.offChange(callback)