Offline first approach for models?

Hey folks,

I'm working on an app where I'd like to use an "offline first" approach; to that end, I'm trying to integrate PouchDB for handling the local data, with an eventual CouchDB backend. I have been going through the Model/Collection/Source/Store docs and API info, but I am still not sure how best to design and implement a solution for this.

As I understand it: enyo.Store keeps local copies of all enyo.Model and enyo.Collection objects, and uses enyo.Source (if necessary) to fetch objects from a remote server. However, I am not sure how to leverage these objects (or subkinds of these objects) to instead use PouchDB as the canonical data source.

Originally I was thinking that I would just write a new Source for fetching objects from PouchDB, but then once PouchDB is synching with a server I'm not sure if I'd run into problems with keeping the Store up to date (since PouchDB just syncs data on its own schedule). Creating a sub-kind of enyo.Store and rewiring it to use PouchDB for its local data seems like a lot of extraneous effort, and likely to be difficult to maintain.

Any ideas/advice? This is probably a really obvious problem for people who have a more in-depth understanding of the system, but it's the first time I've taken a look at the model stuff in Enyo 2.3/2.4. :)

Comments

  • If you figure this out, I'd love to hear as well. The app I'm evaluating Enyo for needs to work deep inside large buildings, where network connectivity may be spotty, so I'm also looking at an offline-first approach. I'm not set on any particular way to do that, so if there's a non-pouch way to make this work, that's just as good for me.
  • Methinks this is, in fact, not an obvious problem for people with more in-depth understandings of the model-collection-store-source system. I'll post back if I find something that works, but I'm probably just going to have to ignore models and bindings and roll a custom data solution. I haven't been able to come up with an elegant way to transition the model system into an offline first approach, and the documentation is too sparse to effectively co-opt things by writing a custom Store (I have no idea what expected values are likely to come through the parameters passed to a Source, for instance).
  • Onecrayon,

    Did you ever make any progress on this? I am trying to build an app that would use model-collection and store in PouchDB but having issues.
  • Unfortunately, no. I've pretty much stopped using Enyo at this point, sadly. Tried to use the new stuff on a couple of projects, but the documentation was sparse enough and the development speed slow enough that it wasn't worth it (plus honestly I just haven't had much time to work on personal projects recently, so the effort needed to bring Enyo up to speed was better spent finding alternatives and/or rolling my own solutions).
Sign In or Register to comment.