Created
November 10, 2016 21:51
-
-
Save asalant/de82fb53028d85ca7a290fd672b63ae2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
withSerializedSync = function(cls) { | |
var sync = cls.prototype.sync || Backbone.sync; | |
cls.prototype.sync = function() { | |
var args = arguments.length ? Array.prototype.slice.call(arguments,0) : []; | |
if (!this._lastSync) { | |
this._lastSync = sync.apply(this, args); | |
} else { | |
var _this = this; | |
this._lastSync = this._lastSync.then(function() { | |
return sync.apply(_this, args); | |
}); | |
} | |
return this._lastSync; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment