Meteor.status() / offline / Methods queue


My mobile application can go offline and the user can perform actions like adding data thougth forms.
When it goes back online, all methods are executed on server side.
How is it possible to know if all waiting on client side methods have been procceed (empty queue) ?
Can Meteor.Status() be used for that purpose?


Am I the only one to ask myself this question or is it a stupid question?

valid question as I’d also be interested.

It seems that we are the only ones :grinning:

I’m not sure if it’s a real help, but the you can check the array Meteor.connection. _outstandingMethodBlocks, and when it’s empty, you’re set. However, that array is not part of any documented API, so any app leveraging it is on thin ice.

Thanks @peterfkruger.

I did some tests with Meteor.connection. _outstandingMethodBlocks and Meteor.status().status.

As soon as Methods are removed from Meteor.connection. _outstandingMethodBlocks, the value of Meteor.status().status is set to connected. So, I don’t know if it is the right solution but for the moment, i will stay with Meteor.status()

The two things are related to each other, that’s why you see a correlation. Now what needs to be considered is the causality.

As soon as the client is connected again, you’ll see Meteor.status().connected becoming true– yet the outstanding methods (so there are any) are not yet executed.

Once their execution is complete you’ll see Meteor.connection._outstandingMethodBlocks becoming empty.

I didn’t test it yet (please do it yourself and let us know), but logic holds that the answer to your question is that the entries to indicate the outstanding methods must disappear from said array for this condition to become true.

I totally agree with you.
If the goal was to automatically close the application after the execution of the methods this would be a problem.
But here the goal is to warn the user not to close the application because the actions he has done are not saved yet. In this case, the temporal aspect is probably negligible.

For my use case, I prefer to stay on something documentable but always take something more robust. :wink:

1 Like