This is a new version of my old question :
So, thanks to the help of Tom Coleman, I finally figured out how to check if the subscription () is ready or not.
My current code structure is as follows:
/client/app.js: eventsHandle = null; groupsHandle = null; // ... // First Deps.autorun(): // Does not depend on any Session var, should just run every time Deps.autorun(function() { eventsHandle = Meteor.subscribe("events", function() { console.log('Deps.autorun(): Events loaded'); }); }); // Second Deps.autorun(): // contains all subscriptions which are dependent on my Session var "ehash" Deps.autorun(function() { if(Session.get('ehash')) groupsHandle = Meteor.subscribe("groups", Session.get('ehash'), function() { console.log('Deps.autorun(): Groups loaded with ehash: ' + Session.get('ehash')); }); }); // ...
Then I have specific .js and .html files for all the template material in a folder named:
/client/views/ --> <page>.js: Template.x.dataLoaded = function() { if(Session.get('ehash')) if(eventsHandle && groupsHandle && eventsHandle.ready() && groupsHandle.ready()) { console.log('All data loaded!'); singleevent = Events.find({ehash: Session.get('ehash')}).fetch()[0]; return true; } }
This dataLoaded wraps basically everything in the corresponding template and shows the contents when dataLoaded returns true, or shows a load scan.
The problem is that in many cases this does not work, because this data-loading code only runs once. Therefore, if two handles are NOT ready () at the time dataLoaded is started, the content will NEVER appear. In this case, I still see that everything console.log comes from the app.js file (material Deps.autorun ()), but the log "All data is loaded!" never a ride.
So my question is: how do I start repeating this code so that dataLoaded again so that the content ultimately displays?
Best wishes
source share