Flow Router wait for trigger before loading page

Okay my situation is this…

  1. User types a specific address /search/equipment/:id

  2. If they normally typed this, it would return an empty page, however I need to actually visit the page where :id exists.

  3. My current implementation is:

FlowRouter.route('search/equipment/:Id', {
  name: 'search-equipment-result',
  triggersEnter: [function (context) {
     Meteor.subscribe('route.id', context.params.Id, function() {
     Session.set("currentSearch", [Equipment.find().fetch()[0]]);
  }],
  action() {
    BlazeLayout.render('App', { yield: 'search_results_equipment' });
  }
});

What this is supposed to do is check if the :Id exists in the Equipment Collection and if so, then render the appropriate page. But unfortuanately, the page loads prior to this finishing.

FlowRouter is designed to handle subscriptions on the template level, not in the router. So it will always render immediately. You can use triggers to redirect to other pages, though.

How would you recommend doing something like a subscription and then find in between searching a URL and Flow-Router rendering the page?

This is typically done with autorun() in onCreated() and helpers on the template level.

A good blog article on this can be found here:
https://www.discovermeteor.com/blog/template-level-subscriptions/