The offline first Ember Data adapter - backed by Mozilla's Kinto offline first API
Demo: https://ember-kinto-demo.herokuapp.com/
Note: THIS IS STILL A WORK IN-PROGRESS
Create the bucket (ptgamr):
echo '{"data": {"id": "ptgamr"}}' | http POST https://ember-kinto-api.herokuapp.com/v1/buckets --auth="ptgamr:ptgamr" --verbose
Create a collection (task) inside that bucket:
echo '{"data": {"id": "tasks"}}' | http POST https://ember-kinto-api.herokuapp.com/v1/buckets/ptgamr/collections --auth="ptgamr:ptgamr" --verbose
Include the add-on to your application and do the following setup:
// app/adapters/application.js
import { KintoAdapter } from 'ember-kinto';
import Kinto from 'npm:kinto';
const db = new Kinto({
remote: 'https://ember-kinto-api.herokuapp.com/v1/',
bucket: 'ptgamr',
dbPrefix: 'ptgamr', // TODO: should be the authorized user
headers: {
Authorization: 'Basic ' + btoa('ptgamr:ptgamr')
}
});
export default KintoAdapter.extend({
db
});
// app/serializers/application.js
import Ember from 'ember';
import DS from 'ember-data';
export default DS.RESTSerializer.extend({
keyForAttribute(attr) {
return Ember.String.underscore(attr);
}
});
// app/services/store.js
import { KintoStore } from 'ember-kinto';
export default KintoStore;
Will trigger Kinto collection.sync()
, the result of the sync will then be updated back to Ember Data store.
More detail on how Kinto.sync() works
Should be use when receiving update from Websocket (Pusher or your own websocket), the changes will be applied to IndexDB first, then propagated back to Ember Data store
git clone <repository-url>
this repositorycd ember-kinto
npm install
bower install
ember serve
- Visit your app at http://localhost:4200.
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit http://ember-cli.com/.