Skip to content

Commit 3dffbd5

Browse files
committed
fix: the exit event is triggered on restart
Don't destroy the angular module on restart
1 parent 30db0d2 commit 3dffbd5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nativescript-angular/platform-common.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
launchEvent,
3535
LaunchEventData,
3636
exitEvent,
37+
ApplicationEventData,
3738
} from "tns-core-modules/application";
3839
import { TextView } from "tns-core-modules/ui/text-view";
3940

@@ -257,9 +258,16 @@ export class NativeScriptPlatformRef extends PlatformRef {
257258
}
258259
);
259260
const exitCallback = profile(
260-
"nativescript-angular/platform-common.exitCallback", () => {
261+
"nativescript-angular/platform-common.exitCallback", (args: ApplicationEventData) => {
262+
const androidActivity = args.android;
263+
if (androidActivity && !androidActivity.isFinishing()) {
264+
// Exit event was triggered as a part of a restart of the app.
265+
return;
266+
}
267+
261268
const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null;
262269
if (lastModuleRef) {
270+
// Make sure the module is only destroyed once
263271
lastBootstrappedModule = null;
264272

265273
lastModuleRef.destroy();

0 commit comments

Comments
 (0)