Ember-data-offline is an addon that extends ember-data to work in offline mode.
It caches records in the local storage (IndexedDB or equivalents).
ember install ember-data-offline
First, define your application adapter with offline support:
//app/adapters/application.js
import baseAdapter from 'ember-data-offline/adapters/base';
export default baseAdapter.extend({
offlineNamespace: 'foo'//optional
});
Then define a model and a serializer for it:
//app/serializers/application.js
import DS from 'ember-data';
export default DS.RESTSerializer.extend({
});
If your primary key is different from 'id'
, you have to specify it in the adapter and serializer:
// in adapter:
export default appAdapter.extend({
serializerPrimaryKey: '_id',
});
For more information, please, take look at dummy app.
All syncornizations between local storage and backend are queued and performed sequentially.
- fork repo
git clone [email protected]:your-github/ember-data-offline.git
npm i && bower install
- add your feature
- cover with tests
- send PR!
[Licensed under MIT license] 1