Skip to content

Instantly share code, notes, and snippets.

@themeteorchef
Created September 9, 2015 15:23
Show Gist options
  • Select an option

  • Save themeteorchef/4c146fd276e58bdd0815 to your computer and use it in GitHub Desktop.

Select an option

Save themeteorchef/4c146fd276e58bdd0815 to your computer and use it in GitHub Desktop.
Loading based on all subs elsewhere?
<!-- Then in your template, have a helper bound to that session variable routeLoaded... -->
<template name="header">
<header>
{{#if routeLoaded}}
<p>header contents</p>
{{else}}
{{> loader}}
{{/if}}
</header>
</template>
Router.route( 'someRoute', {
path: '/some-route',
template: 'someTemplate',
subscriptions: function(){
var subscriptions = [
Meteor.subscribe( 'someSub1' ),
Meteor.subscribe( 'someSub2' )
];
// This is messy but could be replaced with a loop.
if ( subscriptions[0].ready() && subscriptions[1].ready() ) {
Session.set( "routeLoaded", true );
} else {
Session.set( "routeLoaded", false );
}
return subscriptions;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment