Socket
Socket
Sign inDemoInstall

localforage-backbone

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    localforage-backbone

Backbone.js driver for localForage.


Version published
Weekly downloads
14
increased by180%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

localForage Backbone Build Status

Backbone.js driver for the localForage offline storage library.

Install with bower:

bower install localforage-backbone

Run tests with grunt:

grunt test

Submit issues, pull requests, etc. if something is up! <3

Usage

This library lets you override the sync() method on your collections and models so they're saved to localForage instead of a REST server. Simply override your objects' sync() method with the namespace for your model:

var MyModel = Backbone.Model.extend({
    sync: Backbone.localforage.sync('MyModel')
});

var MyCollection = Backbone.Collection.extend({
    model: MyModel,
    sync: Backbone.localforage.sync('MyCollection')
});

Now whenever you save your collections or models, they'll be saved with localForage!

Warning

This library is only about overriding Backbone.sync, which means that calling collection.remove(model) won't update the offline storage.

The Backbone.Collection.remove function is only about removing a model from a collection, to clean up all references and event listeners, but does not involve a sync operation.

If you want to destroy a model, you should use this code instead:

// retrieve a model by its id and destroy it
collection.get(id).destroy();

// or

// retrieve a model by its index in the collection and destroy it
collection.at(index).destroy();

License

This program is free software; it is distributed under an Apache License.


Copyright (c) 2014 Mozilla (Contributors).

Keywords

FAQs

Last updated on 26 Jun 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc