peerjs icon indicating copy to clipboard operation
peerjs copied to clipboard

Implement connection as EventTarget (allow removing listener)

Open HoffmannP opened this issue 2 years ago • 1 comments

Do you have any plans to implement the connection as an EventTarget so you can use .addEventListener? I'd like to have a way to unsubscribe one listening function and replace it with another listening function.

HoffmannP avatar Jun 01 '22 10:06 HoffmannP

Funny you should ask that. Yes, I do.

It’s just chesterton’s EventEmitter. Is there a good reason, not to use the native EventTarget? I want to unterstand why the original implementors didn’t use the native one, before I make any changes.

In the meantime, you should be able to remove listeners now: https://github.com/primus/eventemitter3/blob/acad2eb2e47b7fd44dbb3f61a930cada3b2c8b39/index.d.ts#L60-L74

jonasgloning avatar Jun 02 '22 13:06 jonasgloning