feat: Added new docs
This commit is contained in:
@@ -4,3 +4,42 @@ sidebar_position: 6
|
||||
title: Creating Channels
|
||||
---
|
||||
|
||||
Both channel <b>channel.query</b> and <b>channel.watch</b> methods ensure that a channel exists and create one otherwise.
|
||||
If all you need is to ensure that a channel exists, you can use <b>channel.create</b>.
|
||||
Typically you use <b>channel.watch</b> client side and <b>channel.create</b> for a server side integration.
|
||||
Channels are unique either by the specified channel id or by the list of members.
|
||||
|
||||
### Creating a Channel Using a Channel ID
|
||||
|
||||
This is typically the best approach if you already have some sort of object in your database that the channel is associated with.
|
||||
As an example if you're building a live-streaming service like Twitch you have a channel for every streamer in your database.
|
||||
|
||||
```dart
|
||||
final channel = client.channel(
|
||||
"messaging",
|
||||
id: "travel",
|
||||
extraData: {
|
||||
"name": "Founder Chat",
|
||||
"image": "http://bit.ly/2O35mws",
|
||||
"members": ["thierry", "tommaso"],
|
||||
},
|
||||
);
|
||||
```
|
||||
|
||||
Note: Note that for client side integrations you'll typically prefer to use channel.watch() instead of channel.create.
|
||||
Channel.watch both creates the channel and watches it at the same time.
|
||||
|
||||
### Creating a Channel for a List of Members
|
||||
|
||||
Channels can be used to create conversations between users.
|
||||
In most cases, you want conversations to be unique and make sure that a group of users have only one channel.
|
||||
|
||||
You can achieve this by leaving the channel ID empty and provide channel type and members.
|
||||
When you do so, the API will ensure that only one channel for the members you specified exists (the order of the members does not matter).
|
||||
|
||||
Note: You cannot add/remove members for channels created this way.
|
||||
|
||||
```dart
|
||||
client.channel("messaging", extraData: {"members": ["thierry", "tommaso"]});
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user