-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into 2023-12-11-merge-main…
…-into-v2
- Loading branch information
Showing
21 changed files
with
1,602 additions
and
533 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
|
@@ -139,6 +139,29 @@ const { channel } = useChannel({ channelName: "your-channel-name", options: { .. | |
}); | ||
``` | ||
|
||
[Subscription filters](https://ably.com/docs/channels#filter-subscribe) are also supported: | ||
|
||
```javascript | ||
const deriveOptions = { filter: 'headers.email == `"[email protected]"` || headers.company == `"domain"`' } | ||
const { channel } = useChannel({ channelName: "your-derived-channel-name", options: { ... }, deriveOptions }, (message) => { | ||
... | ||
}); | ||
``` | ||
|
||
Please note that attempts to publish to a derived channel (the one created or retrieved with a filter expression) will fail. In order to send messages to the channel called _"your-derived-channel-name"_ from the example above, you will need to create another channel instance without a filter expression. | ||
|
||
```javascript | ||
const channelName = "your-derived-channel-name"; | ||
const options = { ... }; | ||
const deriveOptions = { filter: 'headers.email == `"[email protected]"` || headers.company == `"domain"`' } | ||
const callback = (message) => { ... }; | ||
|
||
const { channel: readOnlyChannelInstance } = useChannel({ channelName, options, deriveOptions }, callback); | ||
const { channel: readWriteChannelInstance } = useChannel({ channelName, options }, callback); // NB! No 'deriveOptions' passed here | ||
|
||
readWriteChannelInstance.publish("test-message", { text: "message text" }); | ||
``` | ||
|
||
--- | ||
|
||
### usePresence | ||
|
Oops, something went wrong.