adding unsubscribe(eventName)
Isan-Rivkin opened this issue · 3 comments
Isan-Rivkin commented
Hi, currently unsubscribe
method must take a reference to the handler
and it forces me to keep a reference to it while it may not be ideal for some implementations.
Maybe unsubscribe(eventName)
could be provided based on EventEmitter.removeAllListeners(eventName) and how floodsub
is implemented (inherits EventEmitter).
I don't mind creating PR for this, just wonder if there's an issue with that first,
alanshaw commented
I think that's a good suggestion. We'd need a few PRs to make this happen:
- PR to add a test in this repo and update the documentation
- PR to
js-libp2p
https://github.com/libp2p/js-libp2p/blob/4ed5c039fc8583b62cb1e41284a025f5d8d258bc/src/pubsub.js#L41 to callremoveAllListeners
instead ifhandler == null
- PR to
ipfs-http-client
to do the same thing https://github.com/ipfs/js-ipfs-http-client/blob/bfd71c2bd9a467b166c85eaa7dd5d7fb94e4dfa4/src/pubsub.js#L80
@jacobheun @vasco-santos is that cool with you?
jacobheun commented
@jacobheun @vasco-santos is that cool with you?
Yes, this sounds great.
Isan-Rivkin commented
moved to PR #437