> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: unsubscribe(options: UnsubscribeOptions) # Method package: wixRealtimeFrontend # Method menu location: wixRealtimeFrontend --> unsubscribe # Method Link: https://dev.wix.com/docs/velo/apis/wix-realtime-frontend/unsubscribe.md # Method Description: Unsubscribes from a channel or channel resource. The `unsubscribe()` function unsubscribes from receiving messages published on the specified channel or channel resource. + Use the `channel` property of the `UnsubscribeOptions` object passed to the `options` parameter to unsubscribe from all subscriptions to a specific channel or channel resource. When you unsubscribe from a channel you do not unsubscribe from the resources on that same channel. To no longer receive messages on a channel resource, you must explicitly unsubscribe from the specific resource. + Use the `subscriptionId` property of the `UnsubscribeOptions` object passed to the `options` parameter to unsubscribe from a specific subscription. This option is typically used when you have more than one subscription to the same channel or channel resource and you only want to unsubscribe from one of those subscriptions. Get a subscription's `subscriptionId` from the resolution of the Promise returned when creating the subscription with the [`subscribe()`](#subscribe) function. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Unsubscribe from all subscriptions to a channel ```javascript import wixRealtimeFrontend from 'wix-realtime-frontend'; // ... const someChannel = {"name": "someChannel"}; let subscriptionId1; let subscriptionId2; // first subscription to a channel wixRealtimeFrontend.subscribe(someChannel, messageHandler1) .then( (id) => { subscriptionId1 = id; }) ; // second subscription to the same channel wixRealtimeFrontend.subscribe(someChannel, messageHandler2) .then( (id) => { subscriptionId2 = id; }) ; // ... wixRealtimeFrontend.unsubscribe({"channel": someChannel}) .then( () => { // unsubscribed from all subscriptions to channel } ); // ... function messageHandler1(message, channel){ // handle channel messages } function messageHandler2(message, channel){ // handle channel messages } ``` ## Unsubscribe from a specific subscription to a channel ```javascript import wixRealtimeFrontend from 'wix-realtime-frontend'; // ... const someChannel = {"name": "someChannel"}; let subscriptionId1; let subscriptionId2; // first subscription to a channel wixRealtimeFrontend.subscribe(someChannel, messageHandler1) .then( (id) => { subscriptionId1 = id; }) ; // second subscription to the same channel wixRealtimeFrontend.subscribe(someChannel, messageHandler2) .then( (id) => { subscriptionId2 = id; }) ; // ... wixRealtimeFrontend.unsubscribe({"subscriptionId": subscriptionId1}) .then( () => { // unsubscribed from first subscription to channel } ); // ... function messageHandler1(message, channel){ // handle channel messages } function messageHandler2(message, channel){ // handle channel messages } ``` ---