Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
Hey @master_t , please use the beforeDestroy hook for handling this and for unbinding the listener.
Hey @master_t , please use the beforeDestroy hook for handling this and for unbinding the listener.
Thanks @alex_colombo , I somehow missed that hook when reading the docs!