Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
master_t
Partner - Creator II
Partner - Creator II

Detecting when sheet changes / when extension instance is destoryed

Hellow fellow devs

I'm developing a Qlik Sense extension that monitors the selection state of the app and does some processing in the background that I will not bore you with.

What matters to me is this: I've used this code to monitor the selection state, as suggested in the official documentation:

const app = qlik.currApp();
const selState = app.selectionState();
const listener = () => {
    /* ...do whatever... */
};
selState.OnData.bind(listener);

this works quite well and I receive a callback every time selections change, which is what I want.

However, there is a problem with this implementation that I don't know how to solve. Basically, once registered the listener callback keeps getting called when selections change, even if I move away from the sheet that contains my extension object. This is a problem, because it means my listener code keeps executing even when not needed, creating unwanted side effects.

I thought to solve this it would be a simple matter of unbinding the listener when the user navigates away from the sheet, but I've read the entire documentation and I don't see anything that can help me there. I didn't find a "sheet changed" event, and there doesn't even seem to be an opposite of the "paint" method ("destroy" maybe or something like that) that I could leverage to detect when my extension is out of scope. What would be the best way to do it?

Labels (2)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

Hey @master_t , please use the beforeDestroy hook for handling this and for unbinding the listener.

View solution in original post

2 Replies
alex_colombo
Employee
Employee

Hey @master_t , please use the beforeDestroy hook for handling this and for unbinding the listener.

master_t
Partner - Creator II
Partner - Creator II
Author

Thanks @alex_colombo , I somehow missed that hook when reading the docs!