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:
this.zoomClient.off('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?
Thanks,
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));
this.zoomClient.off('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?
Thanks
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);
this.zoomClient.off('active-share-change', this.onActiveShareChange);
Thanks.
Vic
system
(system)
Closed
June 12, 2021, 11:26am
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.