Skip to content

Instantly share code, notes, and snippets.

@chestozo
Created November 1, 2012 08:59
Show Gist options
  • Save chestozo/3992576 to your computer and use it in GitHub Desktop.
Save chestozo/3992576 to your computer and use it in GitHub Desktop.
var model = models[i];
if (model.done()) {
// do nothing
} else if (model.isLoading()) {
loading.push(model);
} else if (model.canRetry()) {
model.willRetry(); // может как-то по-другому назвать
requesting.push(model);
} else {
model.fail(); // !!new
}
/// New no.Model methods
no.Model.prototype.done = function() {
return this.status === STATUS.OK || this.status === STATUS.ERROR;
};
no.Model.prototype.isLoading = function() {
return this.status === STATUS.LOADING;
};
no.Model.prototype.canRetry // уже есть, но нужно немного допилить
no.Model.prototype.willRetry = function() {
this.retries++;
this.promise = new no.Promise();
this.status = STATUS.LOADING; // Ключ будет (пере)запрошен.
};
no.Model.prototype.fail = function() {
this.status = STATUS.ERROR;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment