Skip to content

feat(client)!: update onEventIteratorStatusChange#212

Merged
dinwwwh merged 1 commit intomainfrom
docs/onEventIteratorStatusChange
Mar 9, 2025
Merged

feat(client)!: update onEventIteratorStatusChange#212
dinwwwh merged 1 commit intomainfrom
docs/onEventIteratorStatusChange

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Mar 9, 2025

Summary by CodeRabbit

  • Documentation

    • Introduced a new guide section on monitoring the status of event streaming connections, complete with usage examples.
  • Enhancements

    • Updated the event streaming functionality to accept a flexible options object for configuring immediate notifications, improving consistency and future scalability.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 9, 2025 3:16am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2025

Walkthrough

The changes introduce a new documentation section detailing the event iterator connection status along with a usage code snippet. The modifications update the onEventIteratorStatusChange function signature to accept an options object (with an optional notifyImmediately flag) instead of a boolean, and adjust associated test cases accordingly. This update enhances parameter consistency across both implementation and tests.

Changes

File(s) Change Summary
apps/.../client/event-iterator.md Added a new "Event Iterator Connection Status" section with guidance and an example code snippet demonstrating the usage of onEventIteratorStatusChange for tracking connection status.
packages/client/src/event-iterator-state.ts
packages/client/src/event-iterator-state.test.ts
Updated the onEventIteratorStatusChange function signature to use an options object (with notifyImmediately) instead of a boolean and modified related tests to reflect this change.

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
Loading

Possibly related PRs

  • unnoq/orpc#182: Related changes that modify the event handling functionality by updating how the onEventIteratorStatusChange function processes and tests event status updates.

Poem

I hop through code with joyful glee,
Tracking connections as clear as can be.
The status flows like a gentle stream,
In every test, I find my dream.
From boolean bounds, I've leaped to options supreme!
— A Rabbit’s Code Song 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 9, 2025

Open in Stackblitz

More templates

@orpc/client

npm i https://pkg.pr.new/@orpc/client@212

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@212

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@212

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@212

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@212

@orpc/server

npm i https://pkg.pr.new/@orpc/server@212

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@212

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@212

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@212

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@212

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@212

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@212

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@212

commit: e7535f4

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/client/src/event-iterator-state.ts (1)

30-33: Good API design update using options object pattern

Changing 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 ?? true
packages/client/src/event-iterator-state.test.ts (1)

74-74: Consider using consistent parameter style in tests

For 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4534675 and e7535f4.

📒 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 pattern

All 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

@dinwwwh dinwwwh merged commit 371be67 into main Mar 9, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant