For the complete documentation index, see llms.txt. This page is also available as Markdown.

graniteEvent

功能说明

订阅系统返回键·主页按钮事件。

  • backEvent — 当发生 Android 返回等后退导航时

  • homeEvent — 当发生返回主页时

类型

graniteEvent.addEventListener(
  event: "backEvent" | "homeEvent",
  args: { onEvent: () => void; onError?: (error: Error) => void },
): () => void;

Params

  • event — 这是要订阅的事件。 backEvent(Android 返回等后退导航), homeEvent(主页跳转)之一。

  • args.onEvent: () => void — 事件发生时会被调用。

  • args.onError?: (error: Error) => void — 当订阅处理过程中发生错误时会被调用。

Response

返回解除订阅的函数 () => void。调用后监听器会被移除。

示例代码

这有帮助吗?