Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions packages/angular/src/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface AppRunOptions<T, K> {
appModuleBootstrap: (reason: NgModuleReason) => Promise<NgModuleRef<T>>;
loadingModule?: (reason: NgModuleReason) => Promise<NgModuleRef<K>>;
launchView?: (reason: NgModuleReason) => AppLaunchView;
embedded?: boolean;
}

if (import.meta['webpackHot']) {
Expand Down Expand Up @@ -213,10 +214,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
if (NativeScriptDebug.isLogEnabled()) {
NativeScriptDebug.bootstrapLog(`Setting RootView to ${ref}`);
}
if (launchEventDone) {
Application.resetRootView({
create: () => ref,
});
if (options.embedded) {
Application.run({ create: () => ref });
} else if (launchEventDone) {
Application.resetRootView({ create: () => ref });
} else {
targetRootView = ref;
}
Expand All @@ -227,10 +228,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
if (NativeScriptDebug.isLogEnabled()) {
NativeScriptDebug.bootstrapLog(`Setting RootView to ${newRoot}`);
}
if (launchEventDone) {
Application.resetRootView({
create: () => newRoot,
});
if (options.embedded) {
Application.run({ create: () => newRoot });
} else if (launchEventDone) {
Application.resetRootView({ create: () => newRoot });
} else {
targetRootView = newRoot;
}
Expand Down Expand Up @@ -393,7 +394,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
oldAddEventListener = global.NativeScriptGlobals.events.addEventListener;
global.NativeScriptGlobals.events.addEventListener = global.NativeScriptGlobals.events[Zone.__symbol__('addEventListener')];
}
Application.on(Application.launchEvent, launchCallback);
if (!options.embedded) {
Application.on(Application.launchEvent, launchCallback);
}
Application.on(Application.exitEvent, exitCallback);
if (oldAddEventListener) {
global.NativeScriptGlobals.events.addEventListener = oldAddEventListener;
Expand Down Expand Up @@ -431,5 +434,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
return;
}

Application.run();
if (options.embedded) {
bootstrapRoot('applaunch');
} else {
Application.run();
}
}