I would like to make an application that works offline as well. Its a very basic game. When offline the user can play and when there is a connection it syncs up the data to mongodb. Is this possible? if not is it possible to create a standalone app that does not require a mongodb connection to work and saves everything locally? I would like to keep using the client mongodb driver though so that I don’t need to change my code.
Thanks a lot! Have you had experience with it using iron:router? do I need to change the subscriptions to make it work with iron:router?
Sorry I don’t have experience using it with Iron Router. @raix may be able to answer your question though.
It will work as long as your set of data is small enough to be loaded in your client side.
I did some tests with a very basic app few weeks ago.
You might also try to install it on a mobile/tablet
Thanks for this I will try it out.
Currently working on intelligent subscriptions - solving the issue with iron-router
You can check if Meteor.status() is connected, if it is, handle the subscription, if not just return the template which will then use the grounded data
Bumping here, I’m currently working in a very similar requirement - cordova app works offline but should sync when online. But still a bit confused regarding the logic behind it.
How does the syncing works? And how to achieve it? Plus, is GroundDB suitable for template-level subscriptions?
@appshore your example seems to be exactly what I need but I couldn’t figure out how you are achieving the syncing when you turn the server on.
I did nothing specific, this is standard behavior with Meteor. If the connection is closed/lost between client and server, the mobile app can still access its internal minimongo db. When connection is back there is synchronization with the server having priority if I’m not mistaken.
Thinking about the case of the OP, I’m not sure it will work. If the mobile app is shutdown, local data in minimongo will be lost.
This is awesomely easy. Thanks.
Anyway, the problem you pointed is a real concern. Does GroundDB address it?
I never used GroundDB.
There is a package that provides persistent storage with minimongo but again I never tried it. https://atmospherejs.com/frozeman/persistent-minimongo
So raix is solving the issue with iron router but for now I would do the subscriptions at Meteor.startup because otherwise you get erratic behavior with the data you see in the client.
sorry for late reply. Have put my cordova project in the freezer. so my info is not current any more.
subscribing to all the data you need from the getgo works thats all I know
Of course this is horrible has far as scaling is concerned…
That’s fine. I’ve just set up a [repo] showing how to play with GroundDB (figured out many people seemed to be confused about it) and how it goes regarding syncing. The results are pretty amazing, apart from the fact we still have to handle all subscriptions on startup.
Feel free to play around with the example, go offline, make changes and see how it persists and syncs. Comments and suggestions are definitely welcomed!
Of course all this lie upon @raix terrific job. Thanks!
Additionally you can persist your minimongo with frozeman:persistent-minimongo
Though you need to make sure, that cancelling your subscription is not clearing your minimongo, otherwise they get removed from local storage too.
After a while I finally was able to build a full-functional mobile app that works both online and offline, syncing when connection is detected and persisting offline even if the app shuts down.
Hello @rafael! Great work. Very-very usefull. Do you have experience with handling authorisation in such app? It is hot question for me because in my app before sync user should authorise. Should I save whole Meteor.users collection on mobile to achive that or it is possible to do remotely?
I’m new to meteor, but have been doing some tests with Iron Router. What exactly is the issue you are trying to solve? Is that still work in progress, or you’ve got a fix?