feat: use decoder as a seed for subscription
weboko opened this issue · comments
This is a feature request
Problem
From #2022 it seems that Filter API is hard-to-understand right now as it makes us do:
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.
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 - #1981
@waku-org/js-waku-developers what do you think about this approach?
As a tradeoff to continue support multiple decoders - we can enable both:
await subscription.subscribe(callback);
await subscription.subscribe(decoder1, callback);
Example of previous attempts to re-think usage of Filter