ipfs-inactive/interface-js-ipfs-core

adding unsubscribe(eventName)

Isan-Rivkin opened this issue · 3 comments

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,

I think that's a good suggestion. We'd need a few PRs to make this happen:

  1. PR to add a test in this repo and update the documentation
  2. PR to js-libp2p https://github.com/libp2p/js-libp2p/blob/4ed5c039fc8583b62cb1e41284a025f5d8d258bc/src/pubsub.js#L41 to call removeAllListeners instead if handler == null
  3. 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 @vasco-santos is that cool with you?

Yes, this sounds great.

moved to PR #437