I’m dispatching Meteor Methods inside Accounts.onLogin
to initialize the app for users. However problem arise when multiple tabs are open, seems like there is an infinite loop going and both tabs tries to call the methods in a loop. Is there a way to avoid this?
Here is my code:
Accounts.onLogin(() => {
Meteor.logoutOtherClients(function(error) {
if (error) {
console.log(`error: ${error.error}`)
}
});
// Meteor Method calls
emptyCartItems.call({}, (error, result) => {
// callback hell of methods here.
})
}
Update
As I’ve investigated further looks like the Accounts.onLogin
is being called in an interval when you have multiple tabs open. So as a result any function inside this code block gets called in a certain interval and shows like its doing an infinite loop when in fact it doesn’t. So how do I prevent this code block from rerunning any function inside Accounts.onLogin()
?