I'm trying to use peer js functionality where we create peers and use the respective event listeners i.e. when the peer is created, closed, connected and other stuff, and i'm trying to use it inside an event listener to make it work something like a service. Something like this:
class Demo extends EventEmitter {
private peer: Peer | null = null;
createPeerConnection() {
this.peer = new Peer();
this.peer.on('open', () => {
// Some stuff done
this.emit("Peer");
});
this.peer.on('close', () => {
// Some more stuff done
this.emit("Closed");
});
}
closePeerConnection() {
this.peer = null;
}
I know the peer has the destroy method, but let's say if for some reason I set the object to null, will the connected event listeners also be removed?