Created
April 25, 2015 11:29
-
-
Save Keeo/8044d577f32bd6b926b3 to your computer and use it in GitHub Desktop.
This file contains 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
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