Hi I would like to be able to delay the splash of my app for a bit here is what I mean.
This is my shell view:
<div>
<!-- ko compose: { view : header }-->
<!--/ko-->
<!-- ko compose: { view : content }-->
<!--/ko-->
This is my shell viewmodel:
define(['plugins/router', 'services/dataService' , 'models/appViewModels'],
function (router,dataService , appViewModels) {
var vm = {
header: ko.observable(),
content: ko.observable(),
activate: activate
};
function activate() {
setActivePage();
}
function setActivePage() {
$.when(dataService.account.isAuthenticated())
.done(function(isAuthenticated) {
setDefaultDisplayPage(isAuthenticated)
}).fail(function(data) {
alert(data);
});
}
function setDefaultDisplayPage(isAuthenticated) {
if (isAuthenticated) {
setHeaderAndContentObservables(appViewModels.header.generalHeader, appViewModels.content.homeContent);
} else {
setHeaderAndContentObservables(appViewModels.header.loginHeader, appViewModels.content.loginContent);
}
}
}
The reson I am using observables instead of a string representation of a path for my view is because in my shell I am deciding if I should sent my user on the login or homepage .
This works perfectly except for one thing in the time that it takes to get the isAuthenticated property from the server the splash screen dissapears and the user is left waiting on a blank page until the data is recieved.
Now I could try getting the data in the main.js file and cache it but I figure main.js should have only app configuration responsibility.
Is there any way to make the call to the server for the data before the shell actually get's binded and the splash screen dissapears?