Function off(event: string, callback: (payload: any) => void): void; Is this "off" function working?

Version: zoom video sdk 1.0.3

I have the following code:

this.zoomClient.on('active-share-change', (resp) => this.onActiveShareChange(resp));

Then, I implemented this “off” event:'active-share-change', (resp) => this.onActiveShareChange(resp));

then, when the page starts, I call “on” again

this.zoomClient.on('active-share-change', (resp) => this.onActiveShareChange(resp));

Now, I have 2 events coming in every time there is someone shares the screen.

I wonder if the “off” is functioning properly. Or, my “off” implementation is not correct.

Can you please let me know?


Hey @joecodingjourney

Thanks for sharing your questions.

You can use a variable or function to save the event handler, use the inline arrow function will create different functions, so it seems off function not working.

Hi Vic,

So, instead of doing the inline arrow, you mean that I should do this instead

this.zoomClient.on('active-share-change', this.onActiveShareChange(resp));'active-share-change', this.onActiveShareChange(resp));

Or, can you please give me a code example with using a variable or function to save the event handler?


Hey @joecodingjourney

If you need to use this in the onActiveShareChange method, you should bind this first, use this.onActiveShareChange = this.onActiveShareChange.bind(this), then pass the function as the parameter:

this.zoomClient.on('active-share-change', this.onActiveShareChange);'active-share-change', this.onActiveShareChange);


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.