orpc-client-event-iterator
Use event iterators in oRPC clients.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use event iterators in oRPC clients.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Quick reference for Better Notify configuration, patterns, and common gotchas
Interactive setup wizard for adding Better Notify to a TypeScript/JavaScript project
Context and API guidance for Better Notify — end-to-end typed notification infrastructure for Node.js
Seamlessly use AI SDK inside your oRPC projects without any extra overhead.
Use oRPC inside an Astro project.
Functions to encode and decode base64url strings (URL-safe variant of base64).
| name | oRPC Client Event Iterator |
| description | Use event iterators in oRPC clients. |
| license | MIT |
| metadata | {"author":"Ali Torki","homepage":"https://github.com/ali-master","version":"1.0.0"} |
An Event Iterator in oRPC behaves like an AsyncGenerator.
const iterator = await client.streaming()
for await (const event of iterator) {
console.log(event.message)
}
const controller = new AbortController()
const iterator = await client.streaming(undefined, { signal: controller.signal })
setTimeout(async () => {
controller.abort()
// or
await iterator.return()
}, 1000)
for await (const event of iterator) {
console.log(event.message)
}
Unlike traditional SSE, the Event Iterator does not auto-retry. Use the Client Retry Plugin.
const iterator = await client.streaming()
try {
for await (const event of iterator) {
console.log(event.message)
}
} catch (error) {
if (error instanceof ORPCError) {
// Handle the error
}
}
consumeEventIteratorimport { consumeEventIterator } from '@orpc/client'
const cancel = consumeEventIterator(client.streaming(), {
onEvent: (event) => console.log(event.message),
onError: (error) => console.error(error),
onSuccess: (value) => console.log(value),
onFinish: (state) => console.log(state),
})
setTimeout(async () => {
await cancel()
}, 1000)
This utility accepts both promises and event iterators. Passing a promise lets it infer the correct error type.