1.2.3 • Published 10 years ago

backbone.customsync v1.2.3

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

Backbone.CustomSync

Build Status Gittip

Backbone.CustomSync is a Backbone.js plugin that allows you to write custom methods for all sync procedures ("read", "create", "update", and "delete"), or only those that you define.

Features

  • AMD, CommonJS and Global compliant
  • Compatible with promise-based syncing
  • Preserves original sync functionality with an xhrSync method

Getting Started

Backbone.CustomSync can be used in both front-end and node applications.

Bower

bower install -S backbone.customsync

NPM

npm install --save backbone.customsync

Usage

Backbone.CustomSync exposes an extended Model and Collection with Backbone.CustomSync.Model and Backbone.CustomSync.Collection.

var Todo = Backbone.CustomSync.Model.extend({

  // called by fetch
  readSync: function (options) {
    if (successful) {
      options.success(response);
    } else {
      options.error(response);
    }
  },

  // called by create and save (if the model is new)
  createSync: function (options) {
    if (successful) {
      options.success(response);
    } else {
      options.error(response);
    }
  },

  // called by save
  updateSync: function (options) {
    if (successful) {
      options.success(response);
    } else {
      options.error(response);
    }
  },

  // called by destroy
  deleteSync: function (options) {
    if (successful) {
      options.success(response);
    } else {
      options.error(response);
    }
  }

});
1.2.3

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago