Matthew Gifford
Matthew Gifford

Reputation: 128

Syncing models in localStorage and remotely in ember.js?

We're currently trying to decide between Backbone, Ember, and Angular for an upcoming project. One thing we'd really like to have for this app is the ability for the app to be able to save information to localStorage while offline and sync with the server when it can connect again. We found something that will allow us to this in Backbone (https://github.com/lucian1900/Backbone.dualStorage). Is this something that has been done in Ember?

Upvotes: 5

Views: 1060

Answers (2)

Magge
Magge

Reputation: 266

I think the ember-data-sync project does exactly what is asked, but it seems to be dead and it's not updated to work with the latest Ember version. :(

Upvotes: 1

sheldonbaker
sheldonbaker

Reputation: 1079

I've been thinking about this myself too, but I'm not sure if it's possible to do this right now. It definitely is a goal of the ember-data team to have this in the future.

In theory, it should just be as simple as, upon detecting a stable network connection, switching your models' adapters to a RESTAdapter (or similar) from a LocalStorageAdapter.

You could take a look at the DS.Store.adapterForType method - it was mentioned by Igor in his talk at Ember Camp when this sort of use case was brought up (closer to the end of the video I believe):

Upvotes: 0

Related Questions