> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/sdk/events/graniteevent.md). Agents can also search and read this documentation through its [MCP server](https://developers-apps-in-toss.toss.im/~gitbook/mcp).

# graniteEvent

### 기능 설명

시스템의 뒤로가기·홈 이동 이벤트를 구독해요.

* `backEvent` — 뒤로가기를 요청했을 때(안드로이드 뒤로가기 등)
* `homeEvent` — 홈으로 이동을 요청했을 때

### 타입

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

**Params**

* `event` — 구독할 이벤트예요. `backEvent`(뒤로가기 요청), `homeEvent`(홈 이동 요청) 중 하나예요.
* `args.onEvent: () => void` — 이벤트가 발생하면 호출돼요.
* `args.onError?: (error: Error) => void` — 구독 처리 중 에러가 발생하면 호출돼요.

**Response**

구독을 해제하는 함수 `() => void`를 반환해요. 이 함수를 호출하면 리스너를 제거해요.

### 예시 코드

```js
import { graniteEvent } from "@apps-in-toss/web-framework";

const unsubscribe = graniteEvent.addEventListener("backEvent", {
  onEvent: () => {
    console.log("뒤로가기 발생");
  },
});

// 구독 해제
unsubscribe();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers-apps-in-toss.toss.im/documentation/sdk/events/graniteevent.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
