Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Partner
Partner

How can you tell when all objects in a Mashup have loaded?

Hi there,

I have a mashup which displays a couple of simple KPI's and charts, but it can take a second or two to load. What I've added is a pulsing company logo on the screen that is hidden once all data is loaded.

However using $(document).ready(function() or window.onload function() fires as soon as the page is built but still waits a second or two for the object data to be pulled. I'm using app.getObject( method to retrieve the object from the app.

Does anyone have any suggestions on how I can check that an object has loaded, as in pulled data and presenting it to the user so I can then fire the change to hide the pulsing logo?

Thanks in advance!

Labels (3)
1 Solution

Accepted Solutions
oz_moyal
New Contributor III

Re: How can you tell when all objects in a Mashup have loaded?

Hi,

There is two things here, 
One is if u want to know if all objects fisnihed loading - ie all app.getObject are resolved. this is u can do in js by storing all the promises and check if all are resolved. or u can also load the objects in sequence:

app.getObject('QVobject-1','xxxxx').then( function ( model ) {
    app.getObject('QVobject-2','xxxxx').then( function ( model ) {
       app.getObject('QVobject-3','xxxxx').then( function ( model ) {
					    document.body.className = "loaded"
       })
    })
 });



but the other issue is that app.getobject is resolved when the the data has loaded, but not when the chart is rendedred, so on slow devices the time difference can be noticed.
I did find a way to see when the chart has finished rendering (but i don't think it is documented, so use on your own risk):

app.visualization.get('xxxxx').then(function (vis) { 
    vis.show("QVobject-1", { noSelections: true }); 
    vis.rendered.promise.then(function () { 
        console.log('Chart Rendered!'); 
    }); 
});

 



View solution in original post

3 Replies
Partner
Partner

Re: How can you tell when all objects in a Mashup have loaded?

Update: I've found that applying the change after calling for the object is slightly better, but there is still lag between this and the object actually being rendered for the user to see.

		app.getObject('QVobject-1','xxxxx').then( function ( model ) {
					    document.body.className = "loaded"
				  });

Would love to know how I can check once all objects are loaded!

oz_moyal
New Contributor III

Re: How can you tell when all objects in a Mashup have loaded?

Hi,

There is two things here, 
One is if u want to know if all objects fisnihed loading - ie all app.getObject are resolved. this is u can do in js by storing all the promises and check if all are resolved. or u can also load the objects in sequence:

app.getObject('QVobject-1','xxxxx').then( function ( model ) {
    app.getObject('QVobject-2','xxxxx').then( function ( model ) {
       app.getObject('QVobject-3','xxxxx').then( function ( model ) {
					    document.body.className = "loaded"
       })
    })
 });



but the other issue is that app.getobject is resolved when the the data has loaded, but not when the chart is rendedred, so on slow devices the time difference can be noticed.
I did find a way to see when the chart has finished rendering (but i don't think it is documented, so use on your own risk):

app.visualization.get('xxxxx').then(function (vis) { 
    vis.show("QVobject-1", { noSelections: true }); 
    vis.rendered.promise.then(function () { 
        console.log('Chart Rendered!'); 
    }); 
});

 



View solution in original post

Partner
Partner

Re: How can you tell when all objects in a Mashup have loaded?

Thanks @oz_moyal , the chaining looks to be a good solution - currently I just took to the slowest one and used that but think it would be good to check them all.

It appears as though when using Chrome to throttle the connection it also slows down the rendering, but when using shared WiFi connections (like on a train) which are truly slow then waiting on the promise worked a treat.