how to make an Ember.js app offline with server sync when available
Asked Answered
I

3

8

is there any library that handles this? like the backbone.offline one?, if not, will this be difficult to implement with Ember.js?

UPDATE

this question has two libraries that can help, Breeze.js and Jaydata..

Immobility answered 27/12, 2012 at 21:30 Comment(4)
Ember doesn't have that feature. I might be wrong, but as I understand, the solution would be implementing an adapter and serializer for browser's localStorage (or something like that) and create the logic to sync once you're back on the internet.Rhetorical
yeah that should work, but i dont know if Ember.js has a central point for backend communication (like Backbone.js sync method)Immobility
I don't know if it has, as far as I know it doesn't, so you'd have to implement one. If I'm not mistaken, something like this is sort of plannedRhetorical
this has some bits that you might find useful.Ambert
H
4

ember-localstorage adapter can be used.

it can be used like other adapters.

App.store = DS.Store.create({
  revision: 11,
  adapter: DS.LSAdapter.create()
});

Another good library for ember and rails is ember-data-sync.js

Extend your App.Store from DS.SyncStore. Define the adapter you want to use for client-side storage:

App.Store = DS.SyncStore.extend({
      revision: 10,
      adapter: DS.IndexedDB.adapter({
        mappings: {
          person: App.Person,
          persons: App.Person,
          contact: App.Contact,
          contacts: App.Contact
        }
      })

});
Hardtop answered 18/4, 2013 at 10:1 Comment(0)
C
3

There is no library for this, but you could implement it with a custom adapter. There isn't much documentation for the adapter API and the only ones available in core so far are RESTAdapter and FixtureAdapter.

What you basically need to do there is implement couple of hooks and plug that into your application's store.

Carrissa answered 2/2, 2013 at 23:42 Comment(0)
F
1

Looking for a solution also, and came upon the ember-sync project.

This project piggy-backs on Ember-Data, is ember-cli-ready, and has a queuing feature that smartly handles backend record CRUD. From my brief look into it, I'd say this is the lead project for Ember.js offline-capable apps.

One critique I'd submit on this project is that it ought to also be capable of adapting with epf.io, which itself is a drop-in replacement for Ember-Data and offers transactional CRUD, nested stores -- and even per-model nested store capabilities.

At the time of writing, this project is still in alpha, though it seems to be heading in the right direction.

Flytrap answered 5/11, 2014 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.