Copy link to clipboard
Copied
Hi i'm facing difficulty in unbinding event listerners
i have some these event listeners
app.encoder.bind('onEncoderJobComplete',$._PPP_.onEncoderJobComplete);
app.encoder.bind('onEncoderJobError',$._PPP_.onEncoderJobError);
here is how i have tried something like this file
QePPro.jsx
//unbind
app.encoder.unbind('onEncoderJobComplete',$._PPP_.onEncoderJobComplete);
app.encoder.unbind('onEncoderJobError',$._PPP_.onEncoderJobError);
//bind
app.encoder.bind('onEncoderJobComplete',$._PPP_.onEncoderJobComplete);
app.encoder.bind('onEncoderJobError',$._PPP_.onEncoderJobError);
Problem: On each logout and login the above events are attaching previous count + 1 , on logout i'm not unbinding it and don't know how to unbind it.
please help me
Copy link to clipboard
Copied
Could you expand on 'each logout and login'? Do you mean within your panel?
Copy link to clipboard
Copied
@Bruce Bullis on logout i was just loading index.html where all imports are there
there are 2 div's which is like
<div id="login_wrapper_div"></div>
<div id="home_wrapper_div"></div>
above unbind code did not work in this scenario
even i tried some thing like this
jsx file
$._QEPPRO_={
exportInToOut : function(outputPresetPath, outputDirPathname, blocking, _filename)
{
..... other codes
.....
app.encoder.unbind('onEncoderJobComplete',$._QEPPRO_.onEncoderJobComplete);
app.encoder.unbind('onEncoderJobError',$._QEPPRO_.onEncoderJobError);
},
removeExportEventListeners(){
app.encoder.unbind('onEncoderJobComplete',$._PPP_.onEncoderJobComplete);
app.encoder.unbind('onEncoderJobError',$._PPP_.onEncoderJobError);
}
}
in javascript side on logout i'm doing something like this
$('#logout_button').on('click',function(){
var csInterface = new CSInterface();
csInterface.evalScript('$._QEPPRO_.removeExportEventListeners()');
});
Even though it won't work , if i logout 2 times then
Copy link to clipboard
Copied
Again...Could you expand on 'each logout and login'? Do you mean within your panel? In what context are you logging in and out?
Copy link to clipboard
Copied
@Bruce Bullis Logout here i meant not closing the panel but when the user presses logout button we show him login page. on press of logout button we try to detatch/unbind all export event listeners.
here is a demo i have prepared for you.
https://codesandbox.io/s/focused-darwin-p3kb5x?file=/src/App.vue
Copy link to clipboard
Copied
Got it.
So that login and logout have no impact on CEP or ExtendScript.
Confirming: You unbind() the messages from your handler functions, but your handler functions still get called?
Copy link to clipboard
Copied
@Bruce Bullis ya still i'm getting messages in the handler functions despite of unbind() with each logout it will add + 1.
Copy link to clipboard
Copied
Confirming: If your panel establishes a binding, and then the users closes the panel and re-opens it, are the bindings disconnected then reconnected (total bound function count = 1), or is another binding added to the previously present binding (total bound function count = 2)?
Copy link to clipboard
Copied
@Bruce Bullis as you said
>>> or is another binding added to the previously present binding (total bound function count = 2)
the above behaviour is happening means your 2nd point.