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
syncStoreandsyncKeywithin the Backbone Model (or Collection): -syncStoreis an object to sync to, such aswindow.sessionStorage. May be a string or function. -syncKeyis 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, andsyncare all supported.