Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

backbone.storageEngine

manage your backbone model/collection sync policy easily, with built-in support for localStorage/chrome.storage

build commands

default build command

npm i grunt-cli -g
npm i

roll you own build

grunt clean dist:<pkg>:<wrapper> uglify

<pkg> might be core / default / full, or localstorage / chromestorage.
look Gruntfile.coffee for details

<wrapper> might be plain / amd / amd-lodash
look wrapper directory for details or simply roll your own wrapper

use localStorage / chrome.storage

    LocalModel = Backbone.Model.extend {
        sync: Backbone.StorageEngine.Engine.LocalStorage.createSync model.name
    }

    ChromeCollection = Backbone.Collection.extend {
        sync: Backbone.StorageEngine.Engine.ChromeStorage.createSync model.collection.name
    }

localStorage powered by jeromegn/Backbone.localStorage, and chrome.storage powered by scryptmouse/Backbone.ChromeStorage

implement your own engine

    MyEngine = Backbone.StorageEngine.Engine.Base.extend {
        constructor: (@name)-> @
        create: (model, options)->
        read: (model, options)->
        update: (model, options)->
        delete: (model, options)->
    }, {
        construct: _.memoize (name)->
            new this name
    }

    MyCollection = Backbone.Collection.extend {
        sync: MyEngine.createSync 'my'
    }

decide which engine to use on the fly

requires Backbone.StorageEngine.Router.LateBind

    BaseModel = Backbone.Model.extend {
        sync: Backbone.StorageEngine.Router.LateBind.createSync (method, model, options)->
            if model.type is 'local'
                Backbone.StorageEngine.Engine.LocalStorage.construct model.name
            else
                MyEngine.construct model.name
    }

About

manage your backbone model/collection sync policy easily, with built-in support for localStorage/chrome.storage

Resources

License

Releases

No releases published

Packages

No packages published