For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/react/Hooks/useLynxGlobalEventListener.md.
  • English
  • Function: useLynxGlobalEventListener()

    useLynxGlobalEventListener<T extends (...args: any[]) => void>(eventName: string, listener: T): void

    useLynxGlobalEventListener helps you addListener as early as possible.

    Type Parameters

    Type Parameter
    T extends (...args: any[]) => void

    Parameters

    ParameterTypeDescription
    eventNamestringEvent name to listen
    listenerTEvent handler

    Returns

    void

    Example

    Use this hooks to listen to event 'exposure' and event 'disexposure'

    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'
        />
      )
    }
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.