A mixin for Backbone.sync to synchronize to session or local storage instead of a remote server.
Usage:
- Mix this object into a Backbone Model (or Collection) using
Backbone.Model.extend(StorageSyncMixin)
(orBackbone.Collection.extend(StorageSyncMixin)
). - Define
syncStore
andsyncKey
within the Backbone Model (or Collection): -syncStore
is an object to sync to, such aswindow.sessionStorage
. May be a string or function. -syncKey
is the property of the object to sync to. May be a string or function. For Backbone Models, this will be used as the model identifier (defined byidAttribute
). - Utilize Backbone Sync methods as normal.
fetch
,save
,destroy
,create
, andsync
are all supported.