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..

Community
  • 1
  • 1
Orlando
  • 9,374
  • 3
  • 56
  • 53
  • 2
    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. – MilkyWayJoe Dec 28 '12 at 16:56
  • yeah that should work, but i dont know if Ember.js has a central point for backend communication (like Backbone.js `sync` method) – Orlando Dec 30 '12 at 02:06
  • 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 planned – MilkyWayJoe Dec 31 '12 at 00:04
  • [this](http://petelepage.com/webapp-codelab/) has some bits that you might find useful. – Alex Navasardyan Jan 04 '13 at 18:37

3 Answers3

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
        }
      })

});
khanmizan
  • 926
  • 9
  • 17
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.

Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
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.

mysterlune
  • 1,691
  • 1
  • 12
  • 12