How to unbind the event listerners in jsx

Community Beginner ,
Aug 05, 2022 Aug 05, 2022

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

 

TOPICS
How to , SDK

Views

135

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 05, 2022 Aug 05, 2022

Copy link to clipboard

Copied

Could you expand on 'each logout and login'? Do you mean within your panel?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 07, 2022 Aug 07, 2022

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 


Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 09, 2022 Aug 09, 2022

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 09, 2022 Aug 09, 2022

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
 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 10, 2022 Aug 10, 2022

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?

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2022 Aug 10, 2022

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 11, 2022 Aug 11, 2022

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)?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

LATEST

@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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines