-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor Filter
to an event-based API
#1682
Conversation
size-limit report 📦
|
ccaaa23
to
bd0ee9f
Compare
ab8f18d
to
9cd3c57
Compare
67a268f
to
dee75fb
Compare
}) | ||
); | ||
} catch (e) { | ||
log.error("Error decoding message", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function and Filter.onRequest
should be updated to allow listeners being notified about errors as I mentioned here https://github.com/waku-org/js-waku/pull/1682/files#r1387338041
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored others.
For onRequest
, this can be tricky since it's an async operation and outside the general flow of subscription. Perhaps introducing a callback/event-emission from the Filter class should be incorporated.
We also cannot use the same event-emitter as Subscription, since its segregated by the pubsub topic.
I'd prefer to revisit this once autosharding is implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's split it into a follow-up task
a0b48ae
to
2891e92
Compare
2891e92
to
7ce7a9c
Compare
await subscription.unsubscribe(["/test/2/waku-filter"]); | ||
try { | ||
await subscription.unsubscribe(["/test/2/waku-filter"]); | ||
} catch (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move away from try/catch in favour of return error enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem
For the Filter API, we currently rely on:
createSusbcription
, and then callawait subscribe(Decoder, Callback)
which is not the most intuitive APISolution
Notes
new API: