This is an important thing to get right. I had just this same problem with my app recently and found a good solution. In my case I was rendering intermediate stages of the data being ready. I wanted to hold off rendering until all of my data was loaded.
Here is how I handled it:
- I created an
autorun for each category of data that I wanted to verify was ready.
- For each category of data I was monitoring, I created a reactive variable that would be set to
true when my data was processed.
- I created a
ready() function that would return the result of all of my data categories being ready.
- I created a template helper function
isDataReady.
- On my template, I surrounded the HTML with an
{{#if isDataReady}} ... {{/if}}.
Now, none of my templates try to render until all of my data is available. No more intermediate states.
In my case I had a 2nd problem. On the server, my admin would load data from files. As the files loaded the resultant data structures would start publishing and publish a few times until all the data was finally loaded.
To stop the intermediate publications I started using Mongo bulk operations. To gain access to them I used the same trick as the meteorhacks:aggregate package. When I use bulk operations the reactive functions (e.g. publish functions) only fire when the data is fully loaded or updated.
Works great for me. I hope you have the same luck!