Created
March 3, 2015 17:18
-
-
Save zxqx/095470e012c1a59341a6 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
/** | |
* Ensure all async action is done before injecting container view | |
* @param {number} retries | |
* @return {Promise} | |
*/ | |
loadContent(retries = 0) | |
{ | |
var category = this.appConfig.defaultContentCategory; | |
var logoUrl = this.appConfig.logoUrl; | |
this.topStreamingViewModel = this.viewModels.create(TopStreamingViewModel); | |
this.topStreamingViewModel.category = category; | |
var header = await this.setupHeader(logoUrl); | |
var content = await this.setupTopStreamingContent(category); | |
var navBar = await this.setupNavigationBar(); | |
var sidebar = await this.setupSidebar(); | |
.timeout(MAX_FETCH_TIME_ALLOWED) | |
.then(() => { | |
this.loadingState.setToReady(); | |
this.views.removeView(this.loadingIndicator); | |
this.views.addView(this.container); | |
process.nextTick(() => this.container.fadeIn()); | |
}) | |
.catch((e) => { | |
if (retries < MAX_NUMBER_OF_RETRIES_ALLOWED) { | |
this.loadingState.setToRetrying(); | |
return this.loadContent(retries + 1); | |
} | |
else { | |
this.loadingState.setToFailed(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment