Created
November 1, 2012 08:59
-
-
Save chestozo/3992576 to your computer and use it in GitHub Desktop.
no.request vs no.model: https://github.com/pasaran/noscript/blob/master/src/no.request.js#L68-94
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
| 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