@@ -78,41 +78,46 @@ export function bootstrap(appComponentType: any,
7878 return _platform . application ( appProviders ) . bootstrap ( appComponentType ) ;
7979}
8080
81- export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) {
81+ export function nativeScriptBootstrap ( appComponentType : any , customProviders ?: ProviderArray , appOptions ?: AppOptions ) : Promise < ComponentRef > {
8282 if ( appOptions && appOptions . cssFile ) {
8383 application . cssFile = appOptions . cssFile ;
8484 }
85- application . start ( {
86- create : ( ) : Page => {
87- let page = new Page ( ) ;
88- if ( appOptions ) {
89- page . actionBarHidden = appOptions . startPageActionBarHidden ;
90- }
9185
92- let onLoadedHandler = function ( args ) {
93- page . off ( 'loaded' , onLoadedHandler ) ;
94- //profiling.stop('application-start');
95- console . log ( 'Page loaded' ) ;
96- 97- //profiling.start('ng-bootstrap');
98- console . log ( 'BOOTSTRAPPING...' ) ;
99- bootstrap ( appComponentType , customProviders ) . then ( ( appRef ) => {
100- //profiling.stop('ng-bootstrap');
101- console . log ( 'ANGULAR BOOTSTRAP DONE.' ) ;
102- } , ( err ) => {
103- console . log ( 'ERROR BOOTSTRAPPING ANGULAR' ) ;
104- let errorMessage = err . message + "\n\n" + err . stack ;
105- console . log ( errorMessage ) ;
106- 107- let view = new TextView ( ) ;
108- view . text = errorMessage ;
109- page . content = view ;
110- } ) ;
86+ return new Promise ( ( resolve , reject ) => {
87+ application . start ( {
88+ create : ( ) : Page => {
89+ let page = new Page ( ) ;
90+ if ( appOptions ) {
91+ page . actionBarHidden = appOptions . startPageActionBarHidden ;
92+ }
93+ 94+ let onLoadedHandler = function ( args ) {
95+ page . off ( 'loaded' , onLoadedHandler ) ;
96+ //profiling.stop('application-start');
97+ console . log ( 'Page loaded' ) ;
98+ 99+ //profiling.start('ng-bootstrap');
100+ console . log ( 'BOOTSTRAPPING...' ) ;
101+ bootstrap ( appComponentType , customProviders ) . then ( ( appRef ) => {
102+ //profiling.stop('ng-bootstrap');
103+ console . log ( 'ANGULAR BOOTSTRAP DONE.' ) ;
104+ resolve ( appRef ) ;
105+ } , ( err ) => {
106+ console . log ( 'ERROR BOOTSTRAPPING ANGULAR' ) ;
107+ let errorMessage = err . message + "\n\n" + err . stack ;
108+ console . log ( errorMessage ) ;
109+ 110+ let view = new TextView ( ) ;
111+ view . text = errorMessage ;
112+ page . content = view ;
113+ reject ( err ) ;
114+ } ) ;
115+ }
116+ 117+ page . on ( 'loaded' , onLoadedHandler ) ;
118+ 119+ return page ;
111120 }
112- 113- page . on ( 'loaded' , onLoadedHandler ) ;
114- 115- return page ;
116- }
117- } ) ;
121+ } ) ;
122+ } )
118123}
0 commit comments