Remove all event listener

Description
Is there anyway to remove all the event listener on zoom video SDK?

Which Web Video SDK version?
1.5.5

My Code

this.zoomClient.on('user-added')
this.zoomClient.on('user-removed')
this.zoomClient.on('user-updated')

Hi @superprokid .

Thank you for your post Are you looking for an event-listener for all users being removed? If so, we do not have one for all users leaving the session. Here is a full list of our available event-listeners.

Thanks,
Rehema

You should be able to turn off event listeners using the off method -

I’m using it but it’s not working, am I using it wrong?

		removeZoomEvents() {
			this.zoomClient.off('user-added');
			this.zoomClient.off('user-removed');
			this.zoomClient.off('user-updated');
			this.zoomClient.off('video-dimension-change');
			this.zoomClient.off('recording-change');
			this.zoomClient.off('media-sdk-change');
			this.zoomClient.off('auto-play-audio-failed');
			this.zoomClient.off('active-speaker');
			this.zoomClient.off('unmute-audio-consent');
			this.zoomClient.off('audio-statistic-data-change');
			this.zoomClient.off('device-change');
			this.zoomClient.off('video-statistic-data-change');
			this.zoomClient.off('peer-video-state-change');
			this.zoomClient.off('video-active-change');
			this.zoomClient.off('share-content-dimension-change');
			this.zoomClient.off('peer-share-state-change');
			this.zoomClient.off('connection-change');
			this.zoomClient.off('main-session-user-updated');
		},

Unfortunately, I can’t tell from that code snippet.

there is the second parameter “listener” in your code missing

on(event: “user-added”, listener: typeof event_user_add): void
off(event: “user-added”, listener: typeof event_user_add): void

for every listener you need, something like …

function listener_UserAdded( event ) {
    console.log( "userAdded:", event );
}

this.zoomClient.on('user-added', listener_UserAdded);

this.zoomClient.off('user-added', listener_UserAdded);
3 Likes

Thank you for catching that - completely missed it :slight_smile:

I’m using like this

this.zoomClient.on('share-content-dimension-change', async (payload) => {
// Mycode
});

this.zoomClient.off('share-content-dimension-change', () => {});

And it’s not removing the event, any reason why?

have you tried the syntax the separate event listener function?

quá pro the nay phai tang luong

The nen ga moi ko dc tang luong