Iron Router is rendering this template 5-7 times?

Howdy folks, I have something like this running.

If I console.log(“This page was rendered”); it ends up display 5 times!

Shouldn’t it only load once? This is going to end up costing a lot of collection subscriptions, wont it?

SCREENSHOT: http://prnt.sc/eqi29z

Router.route('/groups/manage/:groupId',{
	data:function(){
		
		if( !Meteor.user()){
			Router.go('/');
		}
	},
	waitOn: function(){
		
		if( Router.current().params.groupId != "" ){
			Meteor.subscribe('posts', 'group_by_id',  Router.current().params.groupId );
		}
		
	},
	template:'screen',
	yieldTemplates: {
		'groups_manager': {to: 'content'},
	}
	
});

Interesting note that I briefly see the home page at / as defined on Router.go(’/’); and then it brings me in to the correct page when I CTRL+S and Meteor restarts. It’s super weird.

What am I missing?

This happens on ALL Iron-Router templates in the project (30).

Iron router is reactive, so if anything changes in data or waitOn the route re-runs.

Ahhh right!

So because I’m subscribing to data feeds at various points in the application, it’ll reload?

Yes, something like that. When I started working on my application a couple of years ago, this was driving me nuts. Ever since Meteor has template based subscription I have refactored my code and when what reloads is much more under control now.

Ahh perfect. Thanks for your tip, it will come in useful.

Cheers,