Skip to content

Commit

Permalink
Unsubscribe handling for js and swift.
Browse files Browse the repository at this point in the history
  • Loading branch information
maratal committed Dec 10, 2024
1 parent 4417090 commit fa775da
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 18 deletions.
10 changes: 8 additions & 2 deletions content/chat/connect.textile
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@ for await statusChange in subscription {
}
```

blang[javascript,swift].
To remove the connection status listener, call the <span lang="javascript">@off()@</span><span lang="swift">@unsubscribe()@</span> function returned in the @subscribe()@ response:
blang[javascript].
To remove the connection status listener, call the @off()@ function returned in the @onStatusChange()@ response:

blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from events:

blang[react].

blang[javascript,swift].
```[javascript]
off();
```
Expand Down
9 changes: 8 additions & 1 deletion content/chat/rooms/index.textile
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,15 @@ blang[javascript,swift].
}
```

To remove the room status listener, call the provided <span lang="javascript">@off()@</span><span lang="swift">@unsubscribe()@</span> function:
blang[javascript].
To remove the room status listener, call the @off()@ function returned in the @onStatusChange()@ response:

blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from events:

blang[react].

blang[javascript,swift].
```[javascript]
off();
```
Expand Down
10 changes: 7 additions & 3 deletions content/chat/rooms/messages.textile
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ The following are the properties of a message:

h3(#unsubscribe). Unsubscribe from messages

blang[javascript,swift].
Unsubscribe from messages to remove previously registered listeners.
blang[javascript].
To unsubscribe from messages remove previously registered listener by calling @unsubscribe()@ function returned in the @subscribe()@ response:

Use the <span lang="javascript">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#unsubscribe</span><span lang="swift">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.MessageSubscription.html#unsubscribe</span> function returned in the @subscribe()@ response to remove a listener:
blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from messages:

blang[react].

blang[javascript,swift].
```[javascript]
// Initial subscription
const { unsubscribe } = room.messages.subscribe((message) => console.log(message));
Expand Down
10 changes: 7 additions & 3 deletions content/chat/rooms/occupancy.textile
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ The following are the properties of an occupancy event:

h3(#unsubscribe). Unsubscribe from room occupancy

blang[javascript,swift].
Unsubscribe from room occupancy to remove previously registered listeners.
blang[javascript].
To unsubscribe from room occupancy remove previously registered listener by calling @unsubscribe()@ function returned in the @subscribe()@ response:

Use the <span lang="javascript">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.OccupancySubscriptionResponse.html#unsubscribe</span><span lang="swift">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.OccupancySubscriptionResponse.html#unsubscribe</span> function returned in the @subscribe()@ response to remove a listener:
blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from room occupancy events:

blang[react].

blang[javascript,swift].
```[javascript]
// Initial subscription
const { unsubscribe } = room.occupancy.subscribe((event) => {
Expand Down
10 changes: 7 additions & 3 deletions content/chat/rooms/presence.textile
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,15 @@ The following are the properties of a presence event:

h3(#unsubscribe). Unsubscribe from presence

blang[javascript,swift].
Unsubscribe from online presence to remove previously registered listeners.
blang[javascript].
To unsubscribe from online presence remove previously registered listener by calling @unsubscribe()@ function returned in the @subscribe()@ response:

Use the <span lang="javascript">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.PresenceSubscriptionResponse.html#unsubscribe</span><span lang="swift">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.PresenceSubscription.html#unsubscribe</span> function returned in the @subscribe()@ response to remove a listener:
blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from online presence events:

blang[react].

blang[javascript,swift].
```[javascript]
// Initial subscription
const { unsubscribe } = room.presence.subscribe((event) => {
Expand Down
10 changes: 7 additions & 3 deletions content/chat/rooms/reactions.textile
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ The following are the properties of a room reaction:

h3(#unsubscribe). Unsubscribe from room reactions

blang[javascript,swift].
Unsubscribe from receiving room reactions to remove previously registered listeners.
blang[javascript].
To unsubscribe from room reactions remove previously registered listener by calling @unsubscribe()@ function returned in the @subscribe()@ response:

Use the <span lang="javascript">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomReactionsSubscriptionResponse.html#unsubscribe</span><span lang="swift">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.RoomReactionsSubscriptionResponse.html#unsubscribe</span> function returned in the @subscribe()@ response to remove a listener:
blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from room reactions events:

blang[react].

blang[javascript,swift].
```[javascript]
// Initial subscription
const {unsubscribe} = room.reactions.subscribe((reaction) => {
Expand Down
10 changes: 7 additions & 3 deletions content/chat/rooms/typing.textile
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,15 @@ You can use the size of the @currentlyTyping@ set to decide whether to display i

h3(#unsubscribe). Unsubscribe from typing events

blang[javascript,swift].
Unsubscribe from typing events to remove previously registered listeners.
blang[javascript].
To unsubscribe from typing events remove previously registered listener by calling @unsubscribe()@ function returned in the @subscribe()@ response:

Use the <span lang="javascript">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.TypingSubscriptionResponse.html#unsubscribe</span><span lang="swift">"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.TypingSubscription.html#unsubscribe</span> function returned in the @subscribe()@ response to remove a listener:
blang[swift].
You can use the provided @unsubscribe()@ method on the returned subscription to unsubscribe from typing events:

blang[react].

blang[javascript,swift].
```[javascript]
// Initial subscription
const { unsubscribe } = room.typing.subscribe((event) => {
Expand Down

0 comments on commit fa775da

Please sign in to comment.