-
Notifications
You must be signed in to change notification settings - Fork 300
Added channel helper docs #2711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis change updates documentation for real-time APIs in a Markdoc file by introducing Channel helper usage throughout code examples. It replaces raw string channel identifiers with a fluent API approach (Channel.bucket().file().toString(), Channel.account(), etc.). The update includes a new "Channel helpers" section documenting the fluent API with examples across multiple client languages (JavaScript, Flutter, Swift, Kotlin), extends existing channel tables to show helper signatures alongside raw channel IDs, and adds guidance on event filtering using .create(), .update(), and .delete() methods. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/routes/docs/apis/realtime/+page.markdoc (2)
60-66: Bug: Variable name mismatch in Swift example.Line 62 references
message.events!, but the closure parameter is namedresponse. This will cause a compile error.🐛 Proposed fix
// Subscribe to files channel using Channel helper let subscription = realtime.subscribe(channels: [Channel.bucket().file().toString()]) { response in - if (message.events!.contains("buckets.*.files.*.create")) { + if (response.events!.contains("buckets.*.files.*.create")) { // Log when a new file is uploaded print(String(describing: response)) } }
246-250: Missing semicolon in Dart example.Dart statements should end with a semicolon. The
listen()call is missing its terminating semicolon.Proposed fix
subscription.stream.listen((response) { // Callback will be executed on all account events. print(response); -}) +});Note: The same issue appears in other Flutter examples at lines 331 and 413.
🤖 Fix all issues with AI agents
In `@src/routes/docs/apis/realtime/`+page.markdoc:
- Around line 581-595: Fix the two typos in the table descriptions: change the
string "to a any team" to "to any team" for the teams entry (near the `teams` /
`Channel.team().toString()` block) and change "to a any membership" to "to any
membership" for the memberships entry (near the `memberships` /
`Channel.membership().toString()` block); update the plain text in +page.markdoc
so the descriptions read "Any create/update/delete events to any team" and "Any
create/update/delete events to any membership" respectively.
🧹 Nitpick comments (2)
src/routes/docs/apis/realtime/+page.markdoc (2)
189-194: Clarify when.toString()is required.The documentation shows
Channel.account()used directly (lines 110, 223) but chained calls likeChannel.database(...).collection(...).document(...)always use.toString(). The guidance "when needed" may confuse developers.Consider explicitly stating which helpers return strings directly versus which require
.toString(), or standardize by always using.toString()for consistency.
611-617: Consider adding a code example for event filtering.The event filtering methods (
.create(),.update(),.delete()) are documented but not demonstrated in the code examples throughout the page. A brief example showing actual usage in a subscription call would help developers understand how to apply these filters.
| * `teams` | ||
| * `Channel.team().toString()` | ||
| * Any create/update/delete events to a any team | ||
| --- | ||
| * `teams.[ID]` | ||
| * `Channel.team(ID).toString()` | ||
| * Any update/delete events to a given team | ||
| --- | ||
| * `memberships` | ||
| * `Channel.membership().toString()` | ||
| * Any create/update/delete events to a any membership | ||
| --- | ||
| * `memberships.[ID]` | ||
| * `Channel.membership(ID).toString()` | ||
| * Any update/delete events to a given membership |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typos in table descriptions.
- Line 583: "to a any team" → "to any team"
- Line 591: "to a any membership" → "to any membership"
Proposed fix
* `teams`
* `Channel.team().toString()`
-* Any create/update/delete events to a any team
+* Any create/update/delete events to any team
---
* `teams.[ID]`
* `Channel.team(ID).toString()`
* Any update/delete events to a given team
---
* `memberships`
* `Channel.membership().toString()`
-* Any create/update/delete events to a any membership
+* Any create/update/delete events to any membership📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| * `teams` | |
| * `Channel.team().toString()` | |
| * Any create/update/delete events to a any team | |
| --- | |
| * `teams.[ID]` | |
| * `Channel.team(ID).toString()` | |
| * Any update/delete events to a given team | |
| --- | |
| * `memberships` | |
| * `Channel.membership().toString()` | |
| * Any create/update/delete events to a any membership | |
| --- | |
| * `memberships.[ID]` | |
| * `Channel.membership(ID).toString()` | |
| * Any update/delete events to a given membership | |
| * `teams` | |
| * `Channel.team().toString()` | |
| * Any create/update/delete events to any team | |
| --- | |
| * `teams.[ID]` | |
| * `Channel.team(ID).toString()` | |
| * Any update/delete events to a given team | |
| --- | |
| * `memberships` | |
| * `Channel.membership().toString()` | |
| * Any create/update/delete events to any membership | |
| --- | |
| * `memberships.[ID]` | |
| * `Channel.membership(ID).toString()` | |
| * Any update/delete events to a given membership |
🤖 Prompt for AI Agents
In `@src/routes/docs/apis/realtime/`+page.markdoc around lines 581 - 595, Fix the
two typos in the table descriptions: change the string "to a any team" to "to
any team" for the teams entry (near the `teams` / `Channel.team().toString()`
block) and change "to a any membership" to "to any membership" for the
memberships entry (near the `memberships` / `Channel.membership().toString()`
block); update the plain text in +page.markdoc so the descriptions read "Any
create/update/delete events to any team" and "Any create/update/delete events to
any membership" respectively.
70e5ab7 to
fb2bab0
Compare
|
|
||
| // Subscribe to files channel | ||
| client.subscribe('files', response => { | ||
| client.subscribe(Channel.bucket().file(), response => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be Channel.files() here
|
|
||
| final subscription = realtime.subscribe(['databases.<DATABASE_ID>.tables.<TABLE_ID>.rows.<ROW_ID>', 'files']); | ||
| final subscription = realtime.subscribe([ | ||
| Channel.tablesdb('db1').table('table1').row('row1'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the placeholder values like <DATABASE_ID>
| If you subscribe to the `rows` channel and a row the user is allowed to read is updated, you will receive an object containing information about the event and the updated row. | ||
| If you subscribe to the `documents` channel and a document the user is allowed to read is updated, you will receive an object containing information about the event and the updated document. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep TablesDB scope
| * `teams` | ||
| * `Channel.team()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions for these should be plural like the channel, teams -> Chanel.teams()
What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.