Skip to content

Instantly share code, notes, and snippets.

@cmwelsh
Created June 15, 2013 00:53
Show Gist options
  • Save cmwelsh/5786300 to your computer and use it in GitHub Desktop.
Save cmwelsh/5786300 to your computer and use it in GitHub Desktop.
this.listenTo(this.model, 'change', this._onModelChange);
initialize: function()
{
// Only save every second at most
this._save = _.debounce(this._save, 1000);
},
_onModelChange: function()
{
this._updateTotals();
this._save();
},
_save: _.throttle(function()
{
this.model.save()
}, 1000),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment