feat(client)!: update onEventIteratorStatusChange#212
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes introduce a new documentation section detailing the event iterator connection status along with a usage code snippet. The modifications update the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant EventIterator
participant StatusHandler
Client->>EventIterator: Invoke onEventIteratorStatusChange(options)
EventIterator-->>StatusHandler: Initialize status = "connecting"
StatusHandler->>Client: Notify status "connecting"
alt Successful Connection
EventIterator-->>StatusHandler: Update status to "connected"
StatusHandler->>Client: Notify status "connected"
else Connection Error
EventIterator-->>StatusHandler: Update status to "error"
StatusHandler->>Client: Notify status "error"
end
StatusHandler->>EventIterator: Execute unsubscribe on cleanup
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
More templates
@orpc/client
@orpc/contract
@orpc/openapi-client
@orpc/openapi
@orpc/react-query
@orpc/server
@orpc/standard-server
@orpc/shared
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/client/src/event-iterator-state.ts (1)
30-33: Good API design update using options object patternChanging from a boolean parameter to an options object improves the function's extensibility. This pattern allows for adding more options in the future without breaking the API.
Consider adding JSDoc comments to document the options object and its properties, as this is part of your public API.
+/** + * Subscribe to event iterator status changes + * @param iterator - The iterator to subscribe to + * @param callback - Function called when status changes + * @param options - Configuration options + * @param options.notifyImmediately - Whether to call callback immediately with current status (default: true) + * @returns Unsubscribe function + */ export function onEventIteratorStatusChange( iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void, options: { notifyImmediately?: boolean } = {}, ): () => void { const notifyImmediately = options.notifyImmediately ?? truepackages/client/src/event-iterator-state.test.ts (1)
74-74: Consider using consistent parameter style in testsFor consistency with other test cases, consider explicitly passing an empty options object here.
expect(() => - onEventIteratorStatusChange(unregisteredIterator, callback), + onEventIteratorStatusChange(unregisteredIterator, callback, {}), ).toThrow('Iterator is not registered.')
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/content/docs/client/event-iterator.md(1 hunks)packages/client/src/event-iterator-state.test.ts(2 hunks)packages/client/src/event-iterator-state.ts(1 hunks)
🔇 Additional comments (2)
apps/content/docs/client/event-iterator.md (1)
73-103: Great addition of Event Iterator Connection Status documentation!The new section provides clear guidance on how to track and manage the connection status of event iterators. The code example effectively demonstrates a complete pattern including initialization, status tracking, error handling, and proper cleanup with the unsubscribe function.
packages/client/src/event-iterator-state.test.ts (1)
26-26: Tests properly updated to use the new options object patternAll test cases have been correctly updated to use the new function signature, maintaining test coverage while adapting to the API change.
Also applies to: 33-33, 40-40, 48-48, 57-57
Summary by CodeRabbit
Documentation
Enhancements