Hi,
Lately, I’ve been adding more logic to router based subscription (in iron router’s waitOn, along with some amount of logic in the publish function on the server) Each page has it’s own subscription parameters that are derived by the publish function based on the current URL I send from the client to the server when that particular page is navigated to.
Intermittently I’ve noticed that upon landing on a new route, the subscription function (waitOn) does not fire immediately. It takes a good 15s before the subscription function executes and the documents are available on the client. It is almost as if the router never immediately realized that the route has changed, although the right page is rendered. This “glitch” is immediately rectified when I hard refresh the entire page via the browser. I’m not sure why there is a delay in calling the subscription function.
Note: My collections are not heavy. They hardly have 100 documents. So this is not something that has got to do with the count of records being sent from the server. The issue is something even before this, since the docs are sent over immediately after the subscription is triggered.
I’m trying to understand why this happens intermittently, on random routes.
Router.route('/dashboard', {
name: 'dashboard',
title: 'Home',
layoutTemplate: 'loggedInIndex',
waitOn: function() {
if(Meteor.userId()){
return [
Meteor.subscribe('routerPublication',window.location.href),
Meteor.subscribe('emsXmpAssociationPublication',window.location.href)
];
}
else {
Router.go("/")
}
}
});
My publish function basically takes in the url that is passed and returns the collection based on the URL.
Thanks.