FlowRouter.wait() waits too much?


#1

I need to wait for a subscription to be ready (the roles collection) for FlowRouter to be initialized. I’m using the wait() and initialize() method according to: https://github.com/kadirahq/flow-router/issues/180
In my server/publish.js I publish ‘roles’, in my lib/routes.js I define my routes and:

if (Meteor.isClient) {
  FlowRouter.subscriptions = function() {
      this.register('myRoles', Meteor.subscribe('roles'))
  }
  FlowRouter.wait()
  Tracker.autorun(function() {
    console.log("Is myRoles ready?:", FlowRouter.subsReady("myRoles"));
    console.log("Are all subscriptions ready?:", FlowRouter.subsReady());
  })
}

In my client-side console the subsReady is false, and then does never become ready, it just hangs. If I don’t have a FlowRouter.wait() it does get ready. It seems that the FlowRouter does not continue to finish the subscription at all. All other posts about the ‘waiting for subs’ did not seems to have this problem.


#2

Found the answer. Apparently FlowRouter.subsReady() is only for after initialization.
I had to call Roles.subscriptions.ready() as a check :slight_smile: