I'm reading the documentation at https://github.com/EventedMind/iron-router/blob/devel/Guide.md and I can't get a clear picture on when I would pass a function to the route()
method and when I would pass an object.
Example for rendering a template with data -- passes a function as the second parameter:
Router.route('/post/:_id', function () {
this.render('Post', {
data: function () {
return Posts.findOne({_id: this.params._id});
}
});
});
Example for waiting for a subscription to complete -- passes an object as the second parameter:
Router.route('/post/:_id', {
// this template will be rendered until the subscriptions are ready
loadingTemplate: 'loading',
waitOn: function () {
// return one handle, a function, or an array
return Meteor.subscribe('post', this.params._id);
},
action: function () {
this.render('myTemplate');
}
});
As you can see, some examples in the documentation use one form and some use the other. Generally speaking, when I find some documentation that addresses what I have in mind, it uses a different form than the one I have adopted from following an example elsewhere in the documentation.
What is the relationship between the two forms? How do I mix and match?