Meteor allows my web app to run even if the server is not available. That’s a really cool feature. Yet I’m still struggling to manage set-up things right for all potential scenarios, especially how to deal with an internet connection that breaks down once in a while, e.g. in an Cordova application.
For instance, how can gracefully react on a Meteor.call() call to the server that takes too long? Let me explain my scenario a bit better: Let us assume my client really “needs” information from the server to proceed, i.e. the data can not be “simulated”. Yet, I do not want to have the user wait “forever” if the server connection breaks down.
So I thought the best thing would be to set a timeout in the client-side of the Meteor.method() and inform the caller if the server did not respond in a specific time window. As there is no way to return a value from from Meteor.method() if .isSimulation == true, I assume the best thing to do was to pass a callback method for this.
However, I have no means at all to stop the server-side call then, so it may happen that the server reconnects and will return the result of its server-side Meteor.method() call once it is ready. So I would have to implement another tricky thing to catch these (now unwanted) callbacks from the server-side, which is all together not very elegant.
Maybe I missed something and there is better ways to do that, so I would be happy to hear about that.
I am also wondering if there is any mechanism by which a client can tell if the server connection is up and running or broken down? Or even better, a kind of event that fires when connection state changes?