Skip to content

Commit

Permalink
Merge pull request #100 from kuzzleio/KZL-788-subscribe-shall-return-…
Browse files Browse the repository at this point in the history
…the-roomId

realtime: updated subscribe documentation according to BUG KZL-788
  • Loading branch information
etrousset committed Nov 2, 2018
2 parents 5e81bec + 1bbe70e commit 0fb629f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/sdk-reference/js/6/realtime/count/snippets/count.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function callback (notification) {}

try {
const { roomId } = await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', {}, callback);
const roomId = await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', {}, callback);

const count = await kuzzle.realtime.count(roomId);

Expand Down
10 changes: 2 additions & 8 deletions src/sdk-reference/js/6/realtime/subscribe/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Subscribes by providing a set of filters: messages, document changes and, option
* @param {object} filters
* @param {Function} callback
* @param {object} [options]
* @returns {Promise.<object>}
* @returns {Promise<string>}
*/
subscribe (index, collection, filters, callback, options = null)
```
Expand Down Expand Up @@ -52,13 +52,7 @@ Additional subscription options.

## Resolve

Resolve to an object containing the following properties:

| Property | Type | Description |
| ---------- | ------- | --------------------------------- |
| `roomId` | String | The room ID |
| `channel` | String | The channel ID |

Resolves to a string containing the room ID

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ try {
// Subscribe users notifications
const options = { users: 'all' };

const { roomId } = await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filters, callback, options);
const roomId = await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', filters, callback, options);

// Subscribe to the same room with the second client
const opfions = { users: 'all', volatile: { username: 'nina vkote' } };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function callback (notification) {}

try {
const { roomId } = await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', {}, callback);
const roomId = await kuzzle.realtime.subscribe('nyc-open-data', 'yellow-taxi', {}, callback);

await kuzzle.realtime.unsubscribe(roomId);

Expand Down

0 comments on commit 0fb629f

Please sign in to comment.