-
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 5 commits
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
190 changes: 190 additions & 0 deletions
190
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,190 @@ | ||
| package {{ sdk.namespace | caseDot }} | ||
|
|
||
| class ResolvedChannel(private val value: String) { | ||
| override fun toString(): String { | ||
| return value | ||
| } | ||
| } | ||
|
|
||
| abstract class ActionChannel(protected val base: String) { | ||
| fun create(): ResolvedChannel { | ||
| return ResolvedChannel("$base.create") | ||
| } | ||
|
|
||
| fun update(): ResolvedChannel { | ||
| return ResolvedChannel("$base.update") | ||
| } | ||
|
|
||
| fun delete(): ResolvedChannel { | ||
| return ResolvedChannel("$base.delete") | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class DocumentChannel(base: String) : ActionChannel(base) | ||
|
|
||
| class CollectionChannel( | ||
| private val databaseId: String, | ||
| private val collectionId: String | ||
| ) { | ||
| private val base = "databases.$databaseId.collections.$collectionId" | ||
|
|
||
| fun document(documentId: String = "*"): DocumentChannel { | ||
| return DocumentChannel("$base.documents.$documentId") | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class DatabaseChannel(private val databaseId: String) { | ||
| private val base = "databases.$databaseId" | ||
|
|
||
| fun collection(collectionId: String = "*"): CollectionChannel { | ||
| return CollectionChannel(databaseId, collectionId) | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class RowChannel(base: String) : ActionChannel(base) | ||
|
|
||
| class TableChannel( | ||
| private val databaseId: String, | ||
| private val tableId: String | ||
| ) { | ||
| private val base = "tablesdb.$databaseId.tables.$tableId" | ||
|
|
||
| fun row(rowId: String = "*"): RowChannel { | ||
| return RowChannel("$base.rows.$rowId") | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class TablesDBChannel(private val databaseId: String) { | ||
| private val base = "tablesdb.$databaseId" | ||
|
|
||
| fun table(tableId: String = "*"): TableChannel { | ||
| return TableChannel(databaseId, tableId) | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class FileChannel(base: String) : ActionChannel(base) | ||
|
|
||
| class BucketChannel(private val bucketId: String) { | ||
| private val base = "buckets.$bucketId" | ||
|
|
||
| fun file(fileId: String = "*"): FileChannel { | ||
| return FileChannel("$base.files.$fileId") | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class ExecutionChannel(base: String) : ActionChannel(base) | ||
|
|
||
| class FunctionChannel(private val functionId: String) { | ||
| private val base = "functions.$functionId" | ||
|
|
||
| fun execution(executionId: String = "*"): ExecutionChannel { | ||
| return ExecutionChannel("$base.executions.$executionId") | ||
| } | ||
|
|
||
| override fun toString(): String { | ||
| return base | ||
| } | ||
| } | ||
|
|
||
| class TeamChannel(teamId: String = "*") : ActionChannel("teams.$teamId") | ||
|
|
||
| class MembershipChannel(membershipId: String = "*") : ActionChannel("memberships.$membershipId") | ||
|
|
||
| class Channel { | ||
| companion object { | ||
| /** | ||
| * Generate a database channel builder. | ||
| * | ||
| * @param databaseId The database ID (default: "*") | ||
| * @returns DatabaseChannel | ||
| */ | ||
| fun database(databaseId: String = "*"): DatabaseChannel { | ||
| return DatabaseChannel(databaseId) | ||
| } | ||
|
|
||
| /** | ||
| * Generate a tables database channel builder. | ||
| * | ||
| * @param databaseId The database ID (default: "*") | ||
| * @returns TablesDBChannel | ||
| */ | ||
| fun tablesdb(databaseId: String = "*"): TablesDBChannel { | ||
| return TablesDBChannel(databaseId) | ||
| } | ||
|
|
||
| /** | ||
| * Generate a buckets channel builder. | ||
| * | ||
| * @param bucketId The bucket ID (default: "*") | ||
| * @returns BucketChannel | ||
| */ | ||
| fun buckets(bucketId: String = "*"): BucketChannel { | ||
| return BucketChannel(bucketId) | ||
| } | ||
|
|
||
| /** | ||
| * Generate a functions channel builder. | ||
| * | ||
| * @param functionId The function ID (default: "*") | ||
| * @returns FunctionChannel | ||
| */ | ||
| fun functions(functionId: String = "*"): FunctionChannel { | ||
| return FunctionChannel(functionId) | ||
| } | ||
|
|
||
| /** | ||
| * Generate a teams channel builder. | ||
| * | ||
| * @param teamId The team ID (default: "*") | ||
| * @returns TeamChannel | ||
| */ | ||
| fun teams(teamId: String = "*"): TeamChannel { | ||
| return TeamChannel(teamId) | ||
| } | ||
|
|
||
| /** | ||
| * Generate a memberships channel builder. | ||
| * | ||
| * @param membershipId The membership ID (default: "*") | ||
| * @returns MembershipChannel | ||
| */ | ||
| fun memberships(membershipId: String = "*"): MembershipChannel { | ||
| return MembershipChannel(membershipId) | ||
| } | ||
|
|
||
| /** | ||
| * Generate an account channel string. | ||
| * | ||
| * @param userId The user ID (default: "*") | ||
| * @returns The channel string | ||
| */ | ||
| fun account(userId: String = "*"): String { | ||
| return "account.$userId" | ||
| } | ||
| } | ||
| } | ||
|
|
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.