🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

backbone.storagesync

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backbone.storagesync

Backbone Sync to Web Storage.

2.0.1
latest
Source
npm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

Backbone Storage Sync

Backbone Sync to Web Storage.

Getting Started

Replace the sync method on your model:

import storageSync from 'bacbone.storagesync';

const AwesomeModel = Backbone.Model.extend({
	sync: storageSync()
	...
})

Or with custom namespace:

const AwesomeModel = Backbone.Model.extend({
	sync: storageSync('awesome')
	...
})

Or with custom settings:

const AwesomeModel = Backbone.Model.extend({
	sync: storageSync({
		namespace: 'awesome',
		storage: window.sessionStorage
	})
	...
})

And you're good to go!

Alternative Storage

By default storagesync will use globally localStorage, however you may change it like so:

storageSync.storage = window.sessionStorage

Or if you want a fallback for when Web Storage isn't available:

storageSync.storage = new FakeStorage()

Note: this example uses my fake-storage library

Dependancies

Backbone, and Backbone.$.Deferred must be present.

License

MIT - see LICENSE

Keywords

backbone

FAQs

Package last updated on 12 Apr 2017

Did you know?

Socket

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