From 693f11ed3ddeab0c81d917c81ae6af51aefc4ca7 Mon Sep 17 00:00:00 2001 From: LordGhostX Date: Sun, 29 Oct 2023 13:41:10 +0100 Subject: [PATCH] document @waku/sdk createSubscription() --- docs/guides/js-waku/light-send-receive.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/guides/js-waku/light-send-receive.md b/docs/guides/js-waku/light-send-receive.md index 2831ada..002f0ca 100644 --- a/docs/guides/js-waku/light-send-receive.md +++ b/docs/guides/js-waku/light-send-receive.md @@ -127,11 +127,17 @@ const callback = (wakuMessage) => { console.log(messageObj); }; -// Subscribe to content topics and display new messages -const unsubscribe = await node.filter.subscribe([decoder], callback); +// Create a filter subscription +const subscription = await node.filter.createSubscription(); -// Use the unsubscribe() function to stop receiving messages -// await unsubscribe(); +// Subscribe to content topics and process new messages +await subscription.subscribe([decoder], callback); +``` + +You can use the `subscription.unsubscribe()` function to stop receiving messages from a content topic: + +```js +await subscription.unsubscribe([contentTopic]); ``` :::tip Congratulations!