[solved] Offline (Ground:db) not working

I want to allow my users to login and add information to my Android app while offline. This requires that I use Ground:db to have local copy of the database. It appears that v2 of ground:db is read-only (I’m not sure I’m reading that correctly). I used v0.3.5 in order to have the methodResume function.

I’ve installed ground:db like so

meteor add ground:db@0.3.5

And I’ve added the following lines of code to my app:

if( Meteor.isCordova ) {
  // This represents all of my collections
if( Meteor.isClient ) {

When i have my app loaded and connected, everything is working well. As soon as I turn off my wifi (and thus turn to disconnected), my subscriptions don’t load.

Am I missing something?

What do you mean by subscriptions don’t load?

I’m using FlowRouter, so for example I have the following route

authOnly.route('/', {
  name: 'Projects',
  action: function() {
    BlazeLayout.render('mainlayout', { side: "sidenav", main: "projects" });
  subscriptions: function(params, queryParams) {
    this.register('projects', Meteor.subscribe('projects'));

Then in my projects template, I have

{{#if subsReady 'projects'}}
   {{#each getProjects}}
      // ... show project display 

but my loading template shows indefinately, implying that the subscription doesn’t load. Sorry for the imprecise wording.

Since the ready status of a subscription relies on a “ready” event being sent from the server, and you wouldn’t have a connection to the server if your application is offline, this would be expected behavior. GroundDB should persist your data though so you could do something like only waiting for subscription ready status if Meteor.status().connected === true and show the data that you do have available.

1 Like

I took out the subsReady block, and it indeed works.