waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
162 stars 41 forks source link

feat: use decoder as a seed for subscription #2034

Open weboko opened 1 month ago

weboko commented 1 month ago
This is a **feature request** ## Problem From https://github.com/waku-org/js-waku/issues/2022 it seems that Filter API is hard-to-understand right now as it makes us do: ```ts const { error, subscription } = await node.filter.createSubscription(shardInfoOrPubsubTopic); await subscription.subscribe([decoder], callback); ``` ## Proposed Solutions Based on the fact that `decoder` is a primitive we use always in pair with Filter and it has knowledge on the `pubsubTopic`/`contentTopic` etc - we should use it. ```ts const { error, subscription } = await node.filter.createSubscription(decoder); await subscription.subscribe(callback); // or instead of createSubscription we can use subscribe API const { error, subscription } = await node.filter.subscribe(decoder, callback); await subscription.subscribe(callback); ``` Also it doesn't seems to be used with `many` of other decoders and since one of the requirements is to have all decoders that are provided to use the same `pubsubTopic` - in that case we can just have one subscription per. ## Notes Additional context - https://github.com/waku-org/js-waku/issues/1981
weboko commented 1 month ago

@waku-org/js-waku-developers what do you think about this approach?

As a tradeoff to continue support multiple decoders - we can enable both: