From fa775da124d425939fd853a2f8e07e571b1b5571 Mon Sep 17 00:00:00 2001 From: Marat Al Date: Wed, 11 Dec 2024 00:47:25 +0100 Subject: [PATCH] Unsubscribe handling for js and swift. --- content/chat/connect.textile | 10 ++++++++-- content/chat/rooms/index.textile | 9 ++++++++- content/chat/rooms/messages.textile | 10 +++++++--- content/chat/rooms/occupancy.textile | 10 +++++++--- content/chat/rooms/presence.textile | 10 +++++++--- content/chat/rooms/reactions.textile | 10 +++++++--- content/chat/rooms/typing.textile | 10 +++++++--- 7 files changed, 51 insertions(+), 18 deletions(-) diff --git a/content/chat/connect.textile b/content/chat/connect.textile index 8383f7336b..fe898b0f62 100644 --- a/content/chat/connect.textile +++ b/content/chat/connect.textile @@ -98,9 +98,15 @@ for await statusChange in subscription { } ``` -blang[javascript,swift]. - To remove the connection status listener, call the @off()@@unsubscribe()@ 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(); ``` diff --git a/content/chat/rooms/index.textile b/content/chat/rooms/index.textile index 777f4ab0e5..42c6c46ea5 100644 --- a/content/chat/rooms/index.textile +++ b/content/chat/rooms/index.textile @@ -257,8 +257,15 @@ blang[javascript,swift]. } ``` - To remove the room status listener, call the provided @off()@@unsubscribe()@ 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(); ``` diff --git a/content/chat/rooms/messages.textile b/content/chat/rooms/messages.textile index a6eae352d4..6425c8c212 100644 --- a/content/chat/rooms/messages.textile +++ b/content/chat/rooms/messages.textile @@ -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 "@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#unsubscribe"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.MessageSubscription.html#unsubscribe 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)); diff --git a/content/chat/rooms/occupancy.textile b/content/chat/rooms/occupancy.textile index 73664b1ba3..c28653cce6 100644 --- a/content/chat/rooms/occupancy.textile +++ b/content/chat/rooms/occupancy.textile @@ -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 "@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.OccupancySubscriptionResponse.html#unsubscribe"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.OccupancySubscriptionResponse.html#unsubscribe 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) => { diff --git a/content/chat/rooms/presence.textile b/content/chat/rooms/presence.textile index 6ae3b94a78..0210341dd4 100644 --- a/content/chat/rooms/presence.textile +++ b/content/chat/rooms/presence.textile @@ -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 "@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.PresenceSubscriptionResponse.html#unsubscribe"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.PresenceSubscription.html#unsubscribe 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) => { diff --git a/content/chat/rooms/reactions.textile b/content/chat/rooms/reactions.textile index 7eaf61fd61..3c9ed97af6 100644 --- a/content/chat/rooms/reactions.textile +++ b/content/chat/rooms/reactions.textile @@ -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 "@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.RoomReactionsSubscriptionResponse.html#unsubscribe"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.RoomReactionsSubscriptionResponse.html#unsubscribe 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) => { diff --git a/content/chat/rooms/typing.textile b/content/chat/rooms/typing.textile index 9f8eb8939f..91a92fa3fc 100644 --- a/content/chat/rooms/typing.textile +++ b/content/chat/rooms/typing.textile @@ -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 "@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.TypingSubscriptionResponse.html#unsubscribe"@unsubscribe()@":https://sdk.ably.com/builds/ably/ably-chat-swift/main/typedoc/interfaces/chat.TypingSubscription.html#unsubscribe 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) => {