Name says it all.
JavaScript HTML
Clone or download
Latest commit 97653d8 Dec 31, 2016
Permalink
Failed to load latest commit information.
addon Use `includes` (w/ polyfill) instead of `contains` Oct 21, 2016
app Move actual Adapter and Serializer code into propper ember addon file… Feb 12, 2016
config Make build pass again. Hopefully. Aug 7, 2016
tests Merge pull request #186 from RabbleApp/promise-errors Oct 13, 2016
vendor Terraform the project with a ember-cli generator empty addon. Feb 11, 2016
.bowerrc Terraform the project with a ember-cli generator empty addon. Feb 11, 2016
.editorconfig Make build pass again. Hopefully. Aug 7, 2016
.ember-cli Terraform the project with a ember-cli generator empty addon. Feb 11, 2016
.gitignore Terraform the project with a ember-cli generator empty addon. Feb 11, 2016
.jshintrc Make build pass again. Hopefully. Aug 7, 2016
.npmignore Make build pass again. Hopefully. Aug 7, 2016
.travis.yml Make build pass again. Hopefully. Aug 7, 2016
.vscodeignore Make build pass again. Hopefully. Aug 7, 2016
.watchmanconfig Terraform the project with a ember-cli generator empty addon. Feb 11, 2016
CHANGELOG.md update config files such as package.json, bower, author data, changel… Feb 11, 2016
LICENSE.md update config files such as package.json, bower, author data, changel… Feb 11, 2016
README.md fix readme typo. Feb 18, 2016
bower.json Released 1.0.0 Dec 31, 2016
ember-cli-build.js Make build pass again. Hopefully. Aug 7, 2016
index.js Terraform the project with a ember-cli generator empty addon. Feb 11, 2016
jsconfig.json Make build pass again. Hopefully. Aug 7, 2016
package.json Released 1.0.0 Dec 31, 2016
testem.js Make build pass again. Hopefully. Aug 7, 2016
testem.json Terraform the project with a ember-cli generator empty addon. Feb 11, 2016

README.md

Ember-localstorage-adapter

Build Status

Store your ember application data in localStorage.

Compatible with Ember Data 1.13 and above.

NOTE: New versions of the localStorage adapter are no longer compatible with older versions of Ember Data. For older versions, checkout the pre-beta branch.

Usage

Include this addon in your app with ember install ember-localstorage-adapter and then like all adapters and serializers:

// app/serializers/application.js
import { LSSerializer } from 'ember-localstorage-adapter';

export default LSSerializer.extend();

// app/adapters/application.js
import LSAdapter from 'ember-localstorage-adapter';

export default LSAdapter.extend({
  namespace: 'yournamespace'
});

Local Storage Namespace

All of your application data lives on a single localStorage key, it defaults to DS.LSAdapter but if you supply a namespace option it will store it there:

import LSAdapter from 'ember-localstorage-adapter/adapters/ls-adapter';

export default LSAdapter.extend({
  namespace: 'my app'
});

Models

Whenever the adapter returns a record, it'll also return all relationships, so do not use {async: true} in your model definitions.

Namespace

If your model definition has a url property, the adapter will store the data on that namespace. URL is a weird term in this context, but it makes swapping out adapters simpler by not requiring additional properties on your models.

const List = DS.Model.extend({
  // ...
});
List.reopen({
  url: '/some/url'
});
export default List;

Quota Exceeded Handler

Browser's localStorage has limited space, if you try to commit application data and the browser is out of space, then the adapter will trigger the QUOTA_EXCEEDED_ERR event.

import DS from 'ember-data';
DS.Store.adapter.on('QUOTA_EXCEEDED_ERR', function(records){
  // do stuff
});

DS.Store.commit();

Local Storage Unavailable

When localStorage is not available (typically because the user has explicitly disabled it), the adapter will keep records in memory. When the adapter first discovers that this is the case, it will trigger a persistenceUnavailable event, which the application may use to take any necessary actions.

adapter.on('persistenceUnavailable', function() {
  // Maybe notify the user that their data won't live past the end of the current session
});

License & Copyright

Copyright (c) 2012 Ryan Florence MIT Style license. http://opensource.org/licenses/MIT

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.