Socket
Socket
Sign inDemoInstall

backbone.local

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    backbone.local

An adapter that replaces `Backbone.sync` to save to `window.localStorage` instead of to the server.


Version published
Maintainers
1
Install size
190 kB
Created

Readme

Source

Backbone localStorage Backend

An adapter that replaces Backbone.sync to save to window.localStorage instead of to the server.

Usage

Import backbone.local and attach it to your models and collections:

import {Collection, Model} from 'backbone';
import {LocalStorage} from 'backbone.localstorage';

const SomeCollection = Collection.extend({

  localStorage: new LocalStorage('SomeCollection'), // Uniquely identify this

});

const SomeModel = Model.extend({

  localStorage: new LocalStorage('SomeModel')

});

To synchronise with the server, you can pass the ajaxSync flag to any options:

const myModel = new SomeModel();
myModel.fetch({
  ajaxSync: true  // Fetches from the server
});

myModel.save({
  new: "value"
}, {
  ajaxSync: true  // Pushes back to the server
});

Contributing

Install NodeJS and run yarn or npm i to get your dependencies, then:

  1. Open an issue identifying the fault
  2. Provide a fix, with tests demonstrating the issue
  3. Run npm test
  4. Create a pull request

Acknowledgments

  • Jerome Gravel-Niquet: Wrote the initial backbone.localstorage
  • Mark Woodall: Initial tests (now refactored);
  • Martin Häcker: Many fixes and the test isolation.

Keywords

FAQs

Last updated on 26 Feb 2017

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