The module is under development. It will be available soon.
Backbone helper that alters and add manager methods to Backbone Model and Collection. Provides a local cache to track models and supports LocalStorage. For managing the LocalStorage, Locally plugin is included in the library.
{String} Prefix that will be used for all data to store.
{Boolean} [default:false] Whether or not use compression in the storage.
Returns the Locally Store. Take a look to its API.
- attrs {Object} Attributes for the new instance.
- options {Object} Options for the new instance.
Factory method that returns a model instance and ensures only one is gonna be created with same id. It keeps the instantiated models in a local cache collection.
- attrs {Object} An id or cid for looking up.
Returns a model, by its id or cid, from the local cache collection of the model.
Returns the collection that represents the local cache of the model.
Resets the local cache collection of the model.
- options {Object} Options for the fetch call.
- options.mode {String} [default:server]
-
infinite.
Fetches the model locally if exists. Otherwise, remotelly.
-
server.
Fetches the model remotely.
-
- options.localStorage {Boolean} Whether or not use LocalStorage.
- options.mode {String} [default:server]
- options {Object} Options for the save call.
- options.mode {String} [default:server]
-
client.
Updates the model locally. The changes no synchronized are kept for future pushes.
-
server.
Updates the model both locally and remotely.
-
- options.localStorage {Boolean|Object} Whether or not use LocalStorage or Locally options.
- options.mode {String} [default:server]
- options {Object} Options for the destroy call.
- options.mode {String} [default:server]
-
client.
Deletes the model locally. The destroy change no synchronized is kept for future pushes.
-
server.
Deletes the model both locally and remotely.
-
- options.localStorage {Boolean|Object} Whether or not use LocalStorage.
- options.mode {String} [default:server]
- options {Object} Options for the fetch call.
- options.localStorage {Boolean} Whether or not use LocalStorage.
Fetches the model if it has not been fetched before.
- options {Object} Options for the remote calls.
- options.localStorage {Boolean} Whether or not use LocalStorage.
Pushes the changes performed to the model; create, update or destroy. In case you wish to distingish which call was finished in remote callbacks, an option "method" is passed.
model.push({
success: function (model, response, options) {
// options.method ["create"|"update"|"patch"|"destroy"]
}
})
Returns 'true' if this model has been fetched remotely, 'false' otherwise.
Retrieves a copy of the attributes that have changed since the last server synchronization.
- attr {String} The attribute to check if has been changed.
Returns 'true' in case the model changed since its last sever synchronization, 'false' otherwise.
Returns 'true' if this model has been destroyed locally, 'false' otherwise.
Returns 'true' if this model has been destroyed remotely, 'false' otherwise.
- jQuery
- Underscore.js
- Backbone
- Backbone.Jsonify
- Locally
First install locally all the required development dependencies.
npm install
grunt
grunt test
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Read the CHANGELOG.md file distributed with the project.
Read the LICENSE file distributed with the project.