Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

In interactive Mashup is it better to call app.getObject for all visualizations when loading page or when needed?

Hello everyone,

I have developed a number of mashups and a common requirement is to hide/show visualizations based on selections and button clicks.  For efficient design is it better to call app.getObject for all visualizations when the page loads or call it as and when the event is triggered?

Thanks in advance,

Richard

1 Solution

Accepted Solutions
Alexander_Thor
Employee
Employee

Yes, every getObject call will instantiate the model. So if you are building a single page app for example you'd want to destroy any objects you put in your view when navigating away from it. You might not see the actual visualization on the page but it's still there in the background receiving data and listening for events.

View solution in original post

6 Replies
Alexander_Thor
Employee
Employee

Generally when the event is triggered, otherwise you have objects which are consuming resources in the background but aren't on the page.

Also make sure you call close on any returned models that aren't in use anymore or your app will starting leaking memory very fast if you don't dispose resources you aren't using anymore.

rbartley
Specialist II
Specialist II
Author

Thanks Alex.  When you say "Also make sure you call close on any returned models that aren't in use anymore", could you you mind be more explicit, please?  Which method(s) should I call?  A code example/extract would be helpful.

Thanks in advance.

Alexander_Thor
Employee
Employee

app.getObject().then(function(model) {

  model.close()

})

rbartley
Specialist II
Specialist II
Author

As far as I am aware, the only time I explicitly return the model is when exporting the data.  So, I assume that I would need to close after exporting.  Are there any other cases when the model is implicitly returned or when I might also need to close the model?

Alexander_Thor
Employee
Employee

Yes, every getObject call will instantiate the model. So if you are building a single page app for example you'd want to destroy any objects you put in your view when navigating away from it. You might not see the actual visualization on the page but it's still there in the background receiving data and listening for events.

dionverbeke
Luminary Alumni
Luminary Alumni

Hi Alex,

How do we unlink these visualisations when not visible?

Currently I am doing:

function getQSObjects(page){

        $("#" + page).find("div.QS").each(function() {

            var qsid = $(this).data("qsid")

            var htmlid = $(this).attr('id');

console.log('getObject',htmlid,qsid)

app.getObject(htmlid,qsid).then(function(model){

model.close();

});

   });

app.getObject('QSCALENDAR','Rppjy').then(function(model){

model.close();

});;

};

function closeQSObjects(page){

  $("#" + page).find("div.QS").each(function() {

            var qsid = $(this).data("qsid")

            var htmlid = $(this).attr('id');

console.log('destroyObject',htmlid,qsid)

app.destroySessionObject(qsid);

});

But I am not sure I the destroySessionObject works.

};

Kind Regards,