Created
November 23, 2016 06:08
-
-
Save tsega/d168a50158a16a298fac8a9f08536556 to your computer and use it in GitHub Desktop.
Iron-Router waitOn()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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