---
name: "offGyroscopeChange"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.3.2" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
title: "offGyroscopeChange - 取消监听陀螺仪数据变化事件。"
---

## offGyroscopeChange

> [VERSION] BaseKit >= 2.3.2 | @ray-js/ray >= 0.3.23

> [PLATFORM] iOS, Android

> ⚡ **支持 Promise 调用** — 不传 success / fail / complete 回调时，该方法返回 Promise。

### 描述

取消监听陀螺仪数据变化事件。

### 参数

`(listener: Function)`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `listener` | `(params: Object) => void` | 是 | - |  |

##### offGyroscopeChange.listener(params) 的属性

| 属性 | 类型 | 必填 | 默认值 | 最低版本 | 描述 |
| --- | --- | --- | --- | --- | --- |
| `x` | `number` | 是 | - | `2.3.2` | X 轴 |
| `y` | `number` | 是 | - | `2.3.2` | Y 轴 |
| `z` | `number` | 是 | - | `2.3.2` | Z 轴 |


### 示例代码

#### Demo

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

// 取消监听陀螺仪：先 onGyroscopeChange + startGyroscope 建立监听，再 offGyroscopeChange 取消
onGyroscopeChange(e => console.log(e));
startGyroscope({
  interval: "normal",
  success: () => {},
  fail: error => console.error(error),
});
offGyroscopeChange(
  () => console.log("已取消监听陀螺仪"),
  error => console.error(error)
);
```
