@@ -60,6 +60,7 @@ export interface AppRunOptions<T, K> {
60
60
appModuleBootstrap : ( reason : NgModuleReason ) => Promise < NgModuleRef < T > > ;
61
61
loadingModule ?: ( reason : NgModuleReason ) => Promise < NgModuleRef < K > > ;
62
62
launchView ?: ( reason : NgModuleReason ) => AppLaunchView ;
63
+ embedded ?: boolean ;
63
64
}
64
65
65
66
if ( import . meta[ 'webpackHot' ] ) {
@@ -213,10 +214,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
213
214
if ( NativeScriptDebug . isLogEnabled ( ) ) {
214
215
NativeScriptDebug . bootstrapLog ( `Setting RootView to ${ ref } ` ) ;
215
216
}
216
- if ( launchEventDone ) {
217
- Application . resetRootView ( {
218
- create : ( ) => ref ,
219
- } ) ;
217
+ if ( options . embedded ) {
218
+ Application . run ( { create : ( ) => ref } ) ;
219
+ } else if ( launchEventDone ) {
220
+ Application . resetRootView ( { create : ( ) => ref } ) ;
220
221
} else {
221
222
targetRootView = ref ;
222
223
}
@@ -227,10 +228,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
227
228
if ( NativeScriptDebug . isLogEnabled ( ) ) {
228
229
NativeScriptDebug . bootstrapLog ( `Setting RootView to ${ newRoot } ` ) ;
229
230
}
230
- if ( launchEventDone ) {
231
- Application . resetRootView ( {
232
- create : ( ) => newRoot ,
233
- } ) ;
231
+ if ( options . embedded ) {
232
+ Application . run ( { create : ( ) => newRoot } ) ;
233
+ } else if ( launchEventDone ) {
234
+ Application . resetRootView ( { create : ( ) => newRoot } ) ;
234
235
} else {
235
236
targetRootView = newRoot ;
236
237
}
@@ -393,7 +394,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
393
394
oldAddEventListener = global . NativeScriptGlobals . events . addEventListener ;
394
395
global . NativeScriptGlobals . events . addEventListener = global . NativeScriptGlobals . events [ Zone . __symbol__ ( 'addEventListener' ) ] ;
395
396
}
396
- Application . on ( Application . launchEvent , launchCallback ) ;
397
+ if ( ! options . embedded ) {
398
+ Application . on ( Application . launchEvent , launchCallback ) ;
399
+ }
397
400
Application . on ( Application . exitEvent , exitCallback ) ;
398
401
if ( oldAddEventListener ) {
399
402
global . NativeScriptGlobals . events . addEventListener = oldAddEventListener ;
@@ -431,5 +434,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
431
434
return ;
432
435
}
433
436
434
- Application . run ( ) ;
437
+ if ( options . embedded ) {
438
+ bootstrapRoot ( 'applaunch' ) ;
439
+ } else {
440
+ Application . run ( ) ;
441
+ }
435
442
}
0 commit comments