Skip to content

Instantly share code, notes, and snippets.

@scott-w
Created October 10, 2017 20:38
Show Gist options
  • Save scott-w/567d6cd065249f5cf513fe6b2f3ffdbd to your computer and use it in GitHub Desktop.
Save scott-w/567d6cd065249f5cf513fe6b2f3ffdbd to your computer and use it in GitHub Desktop.
Custom Model Implementation
import { Model } from 'backbone';
export const MyModel = Model.extend({
defaults: {
counter: 0
},
/**
* Increment our counter and return the new value.
* @returns {number} The incremented counter
*/
increment() {
// I'll show our implementation later
},
/**
* Increment the counter by num and return the new value.
* @param {number} num The number to add to the counter.
* @returns {number} The counter + num
*/
addCounter(num) {
// I'll show our implementation later
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment