Skip to content

Commit 5610333

Browse files
committed
feat: support embedded applications
1 parent 92e4ef8 commit 5610333

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

packages/angular/src/lib/application.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
213213
if (NativeScriptDebug.isLogEnabled()) {
214214
NativeScriptDebug.bootstrapLog(`Setting RootView to ${ref}`);
215215
}
216-
if (launchEventDone) {
217-
Application.resetRootView({
218-
create: () => ref,
219-
});
216+
if (options.embedded) {
217+
Application.run({ create: () => ref });
218+
} else if (launchEventDone) {
219+
Application.resetRootView({ create: () => ref });
220220
} else {
221221
targetRootView = ref;
222222
}
@@ -227,10 +227,10 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
227227
if (NativeScriptDebug.isLogEnabled()) {
228228
NativeScriptDebug.bootstrapLog(`Setting RootView to ${newRoot}`);
229229
}
230-
if (launchEventDone) {
231-
Application.resetRootView({
232-
create: () => newRoot,
233-
});
230+
if (options.embedded) {
231+
Application.run({ create: () => newRoot });
232+
} else if (launchEventDone) {
233+
Application.resetRootView({ create: () => newRoot });
234234
} else {
235235
targetRootView = newRoot;
236236
}
@@ -393,7 +393,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
393393
oldAddEventListener = global.NativeScriptGlobals.events.addEventListener;
394394
global.NativeScriptGlobals.events.addEventListener = global.NativeScriptGlobals.events[Zone.__symbol__('addEventListener')];
395395
}
396-
Application.on(Application.launchEvent, launchCallback);
396+
if (!options.embedded) {
397+
Application.on(Application.launchEvent, launchCallback);
398+
}
397399
Application.on(Application.exitEvent, exitCallback);
398400
if (oldAddEventListener) {
399401
global.NativeScriptGlobals.events.addEventListener = oldAddEventListener;
@@ -431,5 +433,9 @@ export function runNativeScriptAngularApp<T, K>(options: AppRunOptions<T, K>) {
431433
return;
432434
}
433435

434-
Application.run();
436+
if (options.embedded) {
437+
bootstrapRoot('applaunch');
438+
} else {
439+
Application.run();
440+
}
435441
}

0 commit comments

Comments
 (0)