Here's the route in question:
this.route('meeting', {
path: '/meeting/:_id',
template: 'meeting',
waitOn: function(){
console.log("iron-router: meeting waitOn");
return Meteor.subscribe('meetings');
},
data: function() {
console.log("iron-router: meeting data");
return Meetings.findOne({"uuid":this.params._id});
},
onBeforeAction: OnBeforeActions.loginRequired,
action: function () {
console.log("iron-router: meeting action");
if (this.ready()) {
this.render();
}
}
});
The meeting
template has a nested calendar
template which contains 28 day
templates. I'm trying to figure out when/why the iron-router data
function is called, because I see this when I load the page:
iron-router: meeting waitOn
iron-router: meeting data
iron-router: meeting data
iron-router: meeting waitOn
iron-router: loginRequired
iron-router: meeting action
iron-router: meeting data
iron-router: meeting data
(28x) iron-router: meeting data
That's a lot of repeated calls to the same thing! Why?
Data is called whenever there is a change to any reactive variable in it. In your case the Meetings
collection.
When your app loads it will re-run whenever each document in your collection is added to the client. It's also run once initially to register reactive dependencies.
It will run multiple times and if there are changes they will be painted to the DOM. If not it will not proceed further to update the DOM. The re-runs are to check for changes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.