---
name: "onGyroscopeChange"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.3.2" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## onGyroscopeChange

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

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

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

### Parameters

`(listener: Function)`

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `listener` | `(params: Object) => void` | Yes | - |  |

##### onGyroscopeChange.listener(params) properties

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `x` | `number` | Yes | - | `2.3.2` | X-axis |
| `y` | `number` | Yes | - | `2.3.2` | Y-axis |
| `z` | `number` | Yes | - | `2.3.2` | Z-axis |


### Examples

#### Demo

```tsx
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),
});
```
