Skip to content

Instantly share code, notes, and snippets.

@Keeo
Created April 25, 2015 11:29
Show Gist options
  • Save Keeo/8044d577f32bd6b926b3 to your computer and use it in GitHub Desktop.
Save Keeo/8044d577f32bd6b926b3 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Mixin.create({
currentRequest: 0,
majax: function (ajax, success, fail) {
var _this = this;
var cr = this.get('currentRequest');
this.set('currentRequest', ++cr);
ajax.then(function (payload) {
if (_this.get('currentRequest') === cr) {
_this.set('currentRequest', 0);
success(payload);
}
}, function (payload) {
if (_this.get('currentRequest') === cr) {
_this.set('currentRequest', 0);
fail(payload);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment