I see older posts where old versions of Iron-router do wait() in before:
before: function() {
// let's make sure that the topPosts subscription is ready and the posts are loaded
if (this.data()) {
// we can then extract the userIds of the authors
var userIds = this.data().map(function(p) { return p.userId });
// and add the authors subscription to the route's waiting list as well
this.subscribe('authors', userIds).wait(); **<--- this guy!**
}
}
Above is from https://www.discovermeteor.com/blog/reactive-joins-in-meteor/
If I add wait() to my OnBeforeAction subscribe, I get these errors:
You called wait() after calling ready() inside the same computation tree.
You can fix this problem in two possible ways:
1) Put all of your wait() calls before any ready() calls.
2) Put your ready() call in its own computation with Deps.autorun.
My waitOn is
waitOn: function() {
return Meteor.subscribe('weeks', this.params.league);
},
and OnBeforeAction
onBeforeAction: function() {
if (this.ready()) {
// we can now get the latest (first in the list) week
var week = SheetData.find().fetch()[0].week;
this.subscribe('standings', this.params.league, week).wait();
this.next();
}
}
If I remove the wait() the render template starts before my subscription is ready. The suggested fixes don't seem applicable. What am I missing?