onGyroscopeChange(listener: Function)

Requires:
BaseKit≥2.3.2@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { onGyroscopeChange } from '@ray-js/ray';

// Promise usage
try {
  const res = await onGyroscopeChange({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Description

Listen for gyroscope data changes (data is returned by the system; accuracy may differ between iOS and Android)

Parameters

ParameterTypeRequiredDescription
Yes

Return Value

None

Examples

import { onGyroscopeChange, startGyroscope } from '@ray-js/ray'

// Listen for gyroscope changes: register onGyroscopeChange first, then startGyroscope to enable the sensor; x/y/z values will be returned via the callback
onGyroscopeChange(e => {
  console.log("Gyroscope x/y/z:", e.x, e.y, e.z);
});
startGyroscope({
  interval: "normal",
  success: () => console.log("Started listening to gyroscope"),
  fail: error => console.error(error),
});