-
Notifications
You must be signed in to change notification settings - Fork 193
Added channel helpers for realtime in the client sdks #1266
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
Open
ArnabChatterjee20k
wants to merge
6
commits into
master
Choose a base branch
from
dat-971
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
29471d1
added channel helpers for realtime in the client sdks
ArnabChatterjee20k 3f13cb1
Add Channel support to SDKs and templates
ArnabChatterjee20k 5d19169
reverted changes
ArnabChatterjee20k b18671f
Refactor Channel references to use NIOCore.Channel and remove unused …
ArnabChatterjee20k fd57b65
Refractor channel to use builder pattern
ArnabChatterjee20k 3e2402d
updated flutter config
ArnabChatterjee20k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
templates/android/library/src/main/java/io/package/Channel.kt.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| package {{ sdk.namespace | caseDot }} | ||
|
|
||
| /** | ||
| * Helper class to generate channel strings for realtime subscriptions. | ||
| */ | ||
| class Channel { | ||
| companion object { | ||
|
|
||
| /** | ||
| * Generate a database channel string. | ||
| * | ||
| * @param databaseId The database ID (default: "*") | ||
| * @param collectionId The collection ID (default: "*") | ||
| * @param documentId The document ID (default: "*") | ||
| * @param action Optional action: "create", "update", or "delete" (default: null) | ||
| * @returns The channel string | ||
| */ | ||
| fun database(databaseId: String = "*", collectionId: String = "*", documentId: String = "*", action: String? = null): String { | ||
| var channel = "databases.$databaseId.collections.$collectionId.documents.$documentId" | ||
| if (action != null) { | ||
| channel += ".$action" | ||
| } | ||
| return channel | ||
| } | ||
|
|
||
| /** | ||
| * Generate a tables database channel string. | ||
| * | ||
| * @param databaseId The database ID (default: "*") | ||
| * @param tableId The table ID (default: "*") | ||
| * @param rowId The row ID (default: "*") | ||
| * @param action Optional action: "create", "update", or "delete" (default: null) | ||
| * @returns The channel string | ||
| */ | ||
| fun tablesdb(databaseId: String = "*", tableId: String = "*", rowId: String = "*", action: String? = null): String { | ||
| var channel = "tablesdb.$databaseId.tables.$tableId.rows.$rowId" | ||
| if (action != null) { | ||
| channel += ".$action" | ||
| } | ||
| return channel | ||
| } | ||
|
|
||
| /** | ||
| * Generate an account channel string. | ||
| * | ||
| * @param userId The user ID (default: "*") | ||
| * @returns The channel string | ||
| */ | ||
| fun account(userId: String = "*"): String { | ||
| return "account.$userId" | ||
| } | ||
|
|
||
| /** | ||
| * Generate a files channel string. | ||
| * | ||
| * @param bucketId The bucket ID (default: "*") | ||
| * @param fileId The file ID (default: "*") | ||
| * @param action Optional action: "create", "update", or "delete" (default: null) | ||
| * @returns The channel string | ||
| */ | ||
| fun files(bucketId: String = "*", fileId: String = "*", action: String? = null): String { | ||
| var channel = "buckets.$bucketId.files.$fileId" | ||
| if (action != null) { | ||
| channel += ".$action" | ||
| } | ||
| return channel | ||
| } | ||
|
|
||
| /** | ||
| * Generate an executions channel string. | ||
| * | ||
| * @param functionId The function ID (default: "*") | ||
| * @param executionId The execution ID (default: "*") | ||
| * @param action Optional action: "create", "update", or "delete" (default: null) | ||
| * @returns The channel string | ||
| */ | ||
| fun executions(functionId: String = "*", executionId: String = "*", action: String? = null): String { | ||
| var channel = "functions.$functionId.executions.$executionId" | ||
| if (action != null) { | ||
| channel += ".$action" | ||
| } | ||
| return channel | ||
| } | ||
|
|
||
| /** | ||
| * Generate a teams channel string. | ||
| * | ||
| * @param teamId The team ID (default: "*") | ||
| * @param action Optional action: "create", "update", or "delete" (default: null) | ||
| * @returns The channel string | ||
| */ | ||
| fun teams(teamId: String = "*", action: String? = null): String { | ||
| var channel = "teams.$teamId" | ||
| if (action != null) { | ||
| channel += ".$action" | ||
| } | ||
| return channel | ||
| } | ||
|
|
||
| /** | ||
| * Generate a memberships channel string. | ||
| * | ||
| * @param membershipId The membership ID (default: "*") | ||
| * @param action Optional action: "create", "update", or "delete" (default: null) | ||
| * @returns The channel string | ||
| */ | ||
| fun memberships(membershipId: String = "*", action: String? = null): String { | ||
| var channel = "memberships.$membershipId" | ||
| if (action != null) { | ||
| channel += ".$action" | ||
| } | ||
| return channel | ||
| } | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| part of '{{ language.params.packageName }}.dart'; | ||
|
|
||
| /// Helper class to generate channel strings for realtime subscriptions. | ||
| class Channel { | ||
| Channel._(); | ||
|
|
||
| /// Generate a database channel string. | ||
| /// | ||
| /// [databaseId] The database ID (default: '*') | ||
| /// [collectionId] The collection ID (default: '*') | ||
| /// [documentId] The document ID (default: '*') | ||
| /// [action] Optional action: 'create', 'update', or 'delete' (default: null) | ||
| static String database({ | ||
| String databaseId = '*', | ||
| String collectionId = '*', | ||
| String documentId = '*', | ||
| String? action, | ||
| }) { | ||
| String channel = 'databases.$databaseId.collections.$collectionId.documents.$documentId'; | ||
| if (action != null) { | ||
| channel += '.$action'; | ||
| } | ||
| return channel; | ||
| } | ||
|
|
||
| /// Generate a tables database channel string. | ||
| /// | ||
| /// [databaseId] The database ID (default: '*') | ||
| /// [tableId] The table ID (default: '*') | ||
| /// [rowId] The row ID (default: '*') | ||
| /// [action] Optional action: 'create', 'update', or 'delete' (default: null) | ||
| static String tablesdb({ | ||
| String databaseId = '*', | ||
| String tableId = '*', | ||
| String rowId = '*', | ||
| String? action, | ||
| }) { | ||
| String channel = 'tablesdb.$databaseId.tables.$tableId.rows.$rowId'; | ||
| if (action != null) { | ||
| channel += '.$action'; | ||
| } | ||
| return channel; | ||
| } | ||
|
|
||
| /// Generate an account channel string. | ||
| /// | ||
| /// [userId] The user ID (default: '*') | ||
| static String account({String userId = '*'}) { | ||
| return 'account.$userId'; | ||
| } | ||
|
|
||
| /// Generate a files channel string. | ||
| /// | ||
| /// [bucketId] The bucket ID (default: '*') | ||
| /// [fileId] The file ID (default: '*') | ||
| /// [action] Optional action: 'create', 'update', or 'delete' (default: null) | ||
| static String files({ | ||
| String bucketId = '*', | ||
| String fileId = '*', | ||
| String? action, | ||
| }) { | ||
| String channel = 'buckets.$bucketId.files.$fileId'; | ||
| if (action != null) { | ||
| channel += '.$action'; | ||
| } | ||
| return channel; | ||
| } | ||
|
|
||
| /// Generate an executions channel string. | ||
| /// | ||
| /// [functionId] The function ID (default: '*') | ||
| /// [executionId] The execution ID (default: '*') | ||
| /// [action] Optional action: 'create', 'update', or 'delete' (default: null) | ||
| static String executions({ | ||
| String functionId = '*', | ||
| String executionId = '*', | ||
| String? action, | ||
| }) { | ||
| String channel = 'functions.$functionId.executions.$executionId'; | ||
| if (action != null) { | ||
| channel += '.$action'; | ||
| } | ||
| return channel; | ||
| } | ||
|
|
||
| /// Generate a teams channel string. | ||
| /// | ||
| /// [teamId] The team ID (default: '*') | ||
| /// [action] Optional action: 'create', 'update', or 'delete' (default: null) | ||
| static String teams({ | ||
| String teamId = '*', | ||
| String? action, | ||
| }) { | ||
| String channel = 'teams.$teamId'; | ||
| if (action != null) { | ||
| channel += '.$action'; | ||
| } | ||
| return channel; | ||
| } | ||
|
|
||
| /// Generate a memberships channel string. | ||
| /// | ||
| /// [membershipId] The membership ID (default: '*') | ||
| /// [action] Optional action: 'create', 'update', or 'delete' (default: null) | ||
| static String memberships({ | ||
| String membershipId = '*', | ||
| String? action, | ||
| }) { | ||
| String channel = 'memberships.$membershipId'; | ||
| if (action != null) { | ||
| channel += '.$action'; | ||
| } | ||
| return channel; | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.