Reputation: 119
Im using meteor + Iron Router and I would like to handle (in the onbefore web hook) the case where meteor auto refreshes all connected clients and redirect to the home route ('/').
Is there a flag to determine when a refresh is caused by meteor live updating vs a client triggered refresh?
Upvotes: 2
Views: 48
Reputation: 2745
An auto-refresh triggered by a code change leaves Session variable values in-tact, whereas a client-triggered refresh will reset them all to null. So, if I understand you correctly, you could check for the presence of a Session variable in the Meteor.startup callback on the client and call Route.go('/') if it's null. Example:
if (Meteor.isClient) {
Meteor.startup(function() {
if (!Session.get('keyKnownToHaveValue')) {
Route.go('/');
}
});
}
Upvotes: 1