Buckets:
| import type { Event } from "@opencode-ai/sdk/v2" | |
| import { useSDK } from "./sdk" | |
| type EventMetadata = { | |
| directory: string | |
| workspace: string | undefined | |
| } | |
| export function useEvent() { | |
| const sdk = useSDK() | |
| function subscribe(handler: (event: Event, metadata: EventMetadata) => void) { | |
| return sdk.event.on("event", (event) => { | |
| if (event.payload.type === "sync") { | |
| return | |
| } | |
| handler(event.payload, { directory: event.directory, workspace: event.workspace }) | |
| }) | |
| } | |
| function on<T extends Event["type"]>( | |
| type: T, | |
| handler: (event: Extract<Event, { type: T }>, metadata: EventMetadata) => void, | |
| ) { | |
| return subscribe((event: Event, metadata: EventMetadata) => { | |
| if (event.type !== type) return | |
| handler(event as Extract<Event, { type: T }>, metadata) | |
| }) | |
| } | |
| return { | |
| subscribe, | |
| on, | |
| } | |
| } | |
Xet Storage Details
- Size:
- 868 Bytes
- Xet hash:
- 644a021059d8a5841c2b490ffc3301a28c42ae473a3e5bca750c5229eb4575da
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.