offDeviceMotionChange(listener: Function)

版本要求:
BaseKit≥2.3.2@ray-js/ray≥0.3.23
支持平台:
iOSAndroid
import { offDeviceMotionChange } from '@ray-js/ray';

// Promise 调用
try {
  const res = await offDeviceMotionChange({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

描述

取消监听设备方向变化事件,参数为空,则取消所有的事件监听。

参数

参数类型必填说明
是

返回值

无

示例代码

import { onDeviceMotionChange, offDeviceMotionChange, stopDeviceMotionListening } from '@ray-js/ray'

// 取消方向监听:先注册一个监听,再传入同一个 listener 精确取消。
// 末尾 stopDeviceMotionListening 的 success 回调作为用例完成信号
//(off 会移除监听组,TTT 需要一个明确的回调来判定用例结束)。
const listener = e => console.log(e);
onDeviceMotionChange(listener);

offDeviceMotionChange(listener);

stopDeviceMotionListening({
  success: () => console.log("offDeviceMotionChange done"),
  fail: error => console.error(error),
});