Skip to content
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

Make WakuRelay API closer to EventEmitter #678

Closed
D4nte opened this issue Apr 5, 2022 · 3 comments
Closed

Make WakuRelay API closer to EventEmitter #678

D4nte opened this issue Apr 5, 2022 · 3 comments

Comments

@D4nte
Copy link
Contributor

D4nte commented Apr 5, 2022

This is a feature request

Problem

The WakuRelay API implements the observer design pattern.
It is reminiscent of NodeJS's EventEmitter, which is a popular interface in the JS that also implement the observer design pattern:

WakuRelay EventEmitter
send emit
addObserver on
deleteObserver removeListener

However, WakuRelay's API is very limited in comparison to EventEmitter.

See https://nodejs.org/api/events.html for details.

When implementing a socket-like usage of js-waku for WebRTC, I have found the lack of once and removeAllListeners limiting.

Note: the API does not use the same function names because WakuRelay extends EventEmitter by transition.

Proposed Solutions

Implement the following methods on WakuRelay:

WakuRelay EventEmitter equivalent
addOnceObserver once
removeAllObservers removeAllListeners

Feel free to implement all methods equivalent but having check I am uncertain there other methods worth it apart from prepend and count.

@fryorcraken fryorcraken added this to Waku Jan 31, 2023
@fryorcraken
Copy link
Collaborator

once does not really work because one cannot trust that the next message arriving on a given content topic is valid and not spam/garbage.

The work done in waku-org/js-noise#14 enables us to already improve the API for a concrete use case.

Iceboxing for now until we have a concrete need or request of API from developers.

@fryorcraken fryorcraken moved this to Icebox in Waku Apr 6, 2023
@weboko
Copy link
Collaborator

weboko commented Oct 27, 2023

@fryorcraken I think current issue lost it's actuality to #1635 so it should be safe to close this one

@fryorcraken
Copy link
Collaborator

#1635 is more around wrappers.

However, happy to close this and just track work based on recent/popular developer feedback.

@github-project-automation github-project-automation bot moved this from Icebox to Done in Waku Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants