2.0.1 • Published 7 years ago

backbone.storagesync v2.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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

2.0.1

7 years ago

2.0.0

7 years ago

1.3.1

8 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago