Skip to content

feat: filter subscription API #1683

Closed
@danisharora099

Description

@danisharora099

Problem

The current Filter implementation has a few gaps:

Dev Ex

  • library consumers are more used to an event-based approach for subscription-like implementations
    • await filter.subscribe(xyz, callback) works can be improved as it unintuitive to use await in a scenario like such
    • filter.subscribe.addEventListener(xyz) feels more intuitive

Readability and Maintainability

Proposed Solutions

API:

  const subscription = await waku.filter.createSubscription(decoders);
  
  subscription.addEventListener(
        createKeyFromDecoder(decoder),
        (evt) => {
         const decodedMessage = evt.detail;
         }
      );

which users are more familiar with.

Along with that, improvements like:

  • separate Filter and Subscription files
  • takes in decoders on Filter.createSubscription() and calls it internally to avoid an extra step
  • use event emitters for Subscription

Notes

Metadata

Metadata

Assignees

Labels

E:Presentation ReadinessSee https://github.com/waku-org/pm/issues/95 for details

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions