@@ -7,7 +7,7 @@ import { DOCUMENT } from '@angular/common';
77
88import { NativeScriptDebug } from './trace' ;
99import { defaultPageFactoryProvider , setRootPage , PageFactory , PAGE_FACTORY , getRootPage } from './platform-providers' ;
10- import { AppHostView , AppHostLaunchAnimationView } from './app-host-view' ;
10+ import { AppHostView , AppHostAsyncView } from './app-host-view' ;
1111
1212export const onBeforeLivesync = new EventEmitter < NgModuleRef < any > > ( ) ;
1313export const onAfterLivesync = new EventEmitter < {
@@ -57,8 +57,19 @@ export interface AppOptions {
5757 cssFile ?: string ;
5858 startPageActionBarHidden ?: boolean ;
5959 hmrOptions ?: HmrOptions ;
60+ /**
61+ * Background color of the root view
62+ */
6063 backgroundColor ?: string ;
64+ /**
65+ * Use animated launch view (async by default)
66+ */
6167 launchView ?: AppLaunchView ;
68+ /**
69+ * When using Async APP_INITIALIZER, set this to `true`.
70+ * (Not needed when using launchView)
71+ */
72+ async ?: boolean ;
6273}
6374
6475export type PlatformFactory = ( extraProviders ?: StaticProvider [ ] ) => PlatformRef ;
@@ -170,16 +181,18 @@ export class NativeScriptPlatformRef extends PlatformRef {
170181 NativeScriptDebug . bootstrapLog ( 'Application launch event fired' ) ;
171182 }
172183
184+ // Create a temp page for root of the renderer
173185 let tempAppHostView : AppHostView ;
174- let animatedHostView : AppHostLaunchAnimationView ;
175- if ( this . appOptions && this . appOptions . launchView ) {
176- animatedHostView = new AppHostLaunchAnimationView ( new Color ( this . appOptions && this . appOptions . backgroundColor ? this . appOptions . backgroundColor : '#fff' ) ) ;
177- this . appOptions . launchView . style . zIndex = 1000 ;
178- animatedHostView . addChild ( this . appOptions . launchView ) ;
179- rootContent = animatedHostView . ngAppRoot ;
180- setRootPage ( < any > animatedHostView ) ;
186+ let tempAppHostAsyncView : AppHostAsyncView ;
187+ if ( this . appOptions && ( this . appOptions . async || this . appOptions . launchView ) ) {
188+ tempAppHostAsyncView = new AppHostAsyncView ( new Color ( this . appOptions && this . appOptions . backgroundColor ? this . appOptions . backgroundColor : '#fff' ) ) ;
189+ if ( this . appOptions . launchView ) {
190+ this . appOptions . launchView . style . zIndex = 1000 ;
191+ tempAppHostAsyncView . addChild ( this . appOptions . launchView ) ;
192+ }
193+ rootContent = tempAppHostAsyncView . ngAppRoot ;
194+ setRootPage ( < any > tempAppHostAsyncView ) ;
181195 } else {
182- // Create a temp page for root of the renderer
183196 tempAppHostView = new AppHostView ( new Color ( this . appOptions && this . appOptions . backgroundColor ? this . appOptions . backgroundColor : '#fff' ) ) ;
184197 setRootPage ( < any > tempAppHostView ) ;
185198 }
@@ -196,10 +209,10 @@ export class NativeScriptPlatformRef extends PlatformRef {
196209 if ( this . appOptions . launchView && this . appOptions . launchView . cleanup ) {
197210 this . appOptions . launchView . cleanup ( ) . then ( ( ) => {
198211 // cleanup any custom launch views
199- animatedHostView . removeChild ( this . appOptions . launchView ) ;
212+ tempAppHostAsyncView . removeChild ( this . appOptions . launchView ) ;
200213 this . appOptions . launchView = null ;
201214 } ) ;
202- } else {
215+ } else if ( tempAppHostView ) {
203216 rootContent = tempAppHostView . content ;
204217 }
205218
@@ -235,13 +248,13 @@ export class NativeScriptPlatformRef extends PlatformRef {
235248 } ) ;
236249 }
237250 bootstrap ( ) ;
238- if ( ! bootstrapPromiseCompleted ) {
239- const errorMessage = "Bootstrap promise didn't resolve" ;
240- if ( NativeScriptDebug . isLogEnabled ( ) ) {
241- NativeScriptDebug . bootstrapLogError ( errorMessage ) ;
242- }
243- rootContent = this . createErrorUI ( errorMessage ) ;
244- }
251+ // if (!bootstrapPromiseCompleted) {
252+ // const errorMessage = "Bootstrap promise didn't resolve";
253+ // if (NativeScriptDebug.isLogEnabled()) {
254+ // NativeScriptDebug.bootstrapLogError(errorMessage);
255+ // }
256+ // rootContent = this.createErrorUI(errorMessage);
257+ // }
245258 args . root = rootContent ;
246259 } ) ;
247260 const exitCallback = profile ( '@nativescript/angular/platform-common.exitCallback' , ( args : ApplicationEventData ) => {
0 commit comments