Skip to content

Instantly share code, notes, and snippets.

@tsega
Created November 23, 2016 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsega/d168a50158a16a298fac8a9f08536556 to your computer and use it in GitHub Desktop.
Save tsega/d168a50158a16a298fac8a9f08536556 to your computer and use it in GitHub Desktop.
Iron-Router waitOn()
// Wait On one or more subscription before loading the page.
Router.route("/", {
name: "home",
waitOn: function () {
return [
Meteor.subscribe('users'),
// any other subscription to wait on
];
},
action: function () {
if (this.ready()) {
// Send user to sign in form, if not logged in
if (!Meteor.userId()) {
Router.go("/sign_in");
} else {
this.render("home");
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment