Better way to know when app is ready


#1

To know if an application is completely loaded I’m subscribing to each visualization promise (from the execute), so when the data is ready in that visualization I mark it as “ready”, when each visualization is marked then I can say that my dashboard is ready.

Then I realized that when I apply filters I have to use a different method. I looked into the documentation and I found the viz-finished event, so I could do something similar. But at the end I have two different pieces of code to check the same thing.

I wonder, is there a better/easier way to do that?


#2

The ChartFactor core object (cf) has a method called isAppLoaded() that for the current Toolkit version it returns true if all the visualizations registered under that object (those obtained with cf.getAllVisualizations()) are ready.

For the next version cf.isAppLoaded() will return a promise instead that will be resolved when all the visualizations are loaded. The reason is to avoid the need of an interval to query this method until the app is loaded.


#3

By the way, by “ready” I mean data ready, not render ready. We have plan to extend it to provide an approximate of when the visualization is rendered, so it can be more accurate.


#4

Hi @eduardo, Is the feature you mentioned about having a way to know when a visual is rendered already out? The thing is that we have a couple of visuals that have high limits and they take a little longer to render than usual. We receive the viz-finished event but the chart is not ready yet.


#5

Yes, two new events were added that fit best these needs: execute:start and execute:stop. You can subscribe to them directly in the aktive instance.

The execute:start will be triggered everytime the visual is executed (it starts the execution process)

The execute:stop will be triggered when the visual process is finished (or failed). Finished process means that if the aktive is only used to query, it will be triggered as soon as the data is ready, if on the other hand it has a visual (chart), then the event will be triggered when is completely rendered.

These events (specially) the execute:stop are better suited for loading indicator purposes or simply to control the state of the visual.