Are multiple channels affect memory or data?

I would recommend fetching all the data that the app/user is authorized to and for each activity to use Query (or LiveQueries) to filter on the data that is applicable for the activity.
Few reasons why you may want to design it this way -

  • Channels are meant to facilitate user-level granularity of data routing and authorization. You would not want to tie in your app workflow logic to channels because if your app activities change (which is very realistic in a real world app) as your app evolves , it wouldn’t be practical to change your sync gateway (which would need to serve older versions of the apps and also what if you have iOS apps with completely different views)
  • If your app is used in offline mode before all the activities have synced across all the channels, you will potentially run into the issue of having inconsistent data across the activities which may be undesirable
  • Trying to sync data at the time when activity is resumed is an anti-pattern to building a responsive app. In other words, one of the goals of doing the continuous replication in the background is to ensure that when your activity is launched, it has more or less the latest snapshot of data. If you are pulling from channels overtime you launch the activity, it isn’t very different that doing an on-demand pull of data
  • You could start with a pre-built database that’s bundled with your app if it “never changes”.

  • But if it is semi-static, you can set one-shot replication mode. You can use Google’s push replication service to notify your app of changes and then do a one-shot replication pull the data. Alternatively , if the changes are not desired in real time, you can trivially do a one-shot replication every time the app is launched to sync any possible changes.

  • Another way is that you can write a special document onto a channel that is anyway being continuously replicated which would be like a trigger for the app to pull the other data.

  • If real time update of semi-static data is a need, note that there isn’t much of an overhead (like data bandwidth usage, battery usage ) keeping the replication open in continuous mode. The main idea of continuous mode is that its hassle free for the app developer.

1 Like