Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
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.
app.getObject().then(function(model) {
model.close()
})
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?
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.
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,