> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Function: useLynxGlobalEventListener()

> **useLynxGlobalEventListener**\<`T` _extends_ (...`args`: `any`\[]) => `void`>(`eventName`: `string`, `listener`: `T`): `void`

`useLynxGlobalEventListener` 帮助你尽早地 `addListener`。

## Type Parameters

| Type Parameter                                |
| --------------------------------------------- |
| `T` _extends_ (...`args`: `any`\[]) => `void` |

## Parameters

| Parameter   | Type     | Description |
| ----------- | -------- | ----------- |
| `eventName` | `string` | 要监听的事件名     |
| `listener`  | `T`      | 事件处理函数      |

## Returns

`void`

## Example

使用此 Hook 监听 'exposure' 事件和 'disexposure' 事件

```jsx
function App() {
  useLynxGlobalEventListener('exposure', (e) => {
    console.log("exposure", e)
  })
  useLynxGlobalEventListener('disexposure', (e) => {
    console.log("disexposure", e)
  })
  return (
    <view
      style='width: 100px; height: 100px; background-color: red;'
      exposure-id='a'
    />
  )
}
```
