I want to “waitOn” the subscriptions before yielding the chatHome template or any other template passed to yield. I’m trying to switch to the pattern of subscribing at the template level. It seems as the Template.subscriptionsReady is always true. It loads the chatHome template and the data starts populating. Now my scrollToBottom() function has already fired and won’t work properly since all the data hasn’t been loaded yet.
I was using pecl:loading in combination with the waitOn iron router hook, but I no longer want to do subscriptions on the router so I can eventually move to flow router.
@nbrady there’s no point of putting Meteor.subscribe("messages") or Meteor.subscribe("userStatus") in autorun, it serves nothing in this case, there are no reactive arguments that would make the subscription to reload.
Also, you do Meteor.subscribe() which doesn’t trigger this.subscriptionReady at all. You need to use this.subscribe.
There is a complementary function Template.instance().subscriptionsReady() which returns true when all of the subscriptions called with this.subscribe are ready.
At this point, the subscriptions work fine and I’ve got the loading template showing until the data is loaded. But it seems that my scrollToBottom() function is firing before all the data has flushed.