I wanted to add a simple connection checker similar to what you see on atmosphere and other meteor sites. If the connection breaks in the app a simple toast is displayed, upon reconnect it goes away. Is there a reactive method already in place for this? Currently I’m checking Meteor.status().connected in a function that’s called by starting a setInterval.
Is this necessary? It works fine I just wanted to see if this was the proper way of handling this.
Looks to me like you’re using angular-meteor. You should change things around to destroy the autorun when the scope destroys (even if it doesn’t). And you’re also calling Meteor.status() multiple times and should be assigned to a variable instead.
$scope.$meteorAutorun(function() {
var status = Meteor.status().status;
if (status === "connected") {
console.log("connected");
$scope.closeToast();
} else if (status === "connecting") {
console.log("reconnecting");
} else {
console.log("disconnected");
$scope.showToastWarning("No connection");
}
});