mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix: application instance creation occurs only within Application.run
This commit is contained in:
@ -159,14 +159,18 @@ export interface AndroidApplication {
|
||||
on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
const androidApp = new AndroidApplication();
|
||||
let androidApp: AndroidApplication;
|
||||
export { androidApp as android };
|
||||
appCommon.setApplication(androidApp);
|
||||
|
||||
let mainEntry: NavigationEntry;
|
||||
let started = false;
|
||||
|
||||
export function run(entry?: NavigationEntry | string) {
|
||||
if (!androidApp) {
|
||||
androidApp = new AndroidApplication();
|
||||
appCommon.setApplication(androidApp);
|
||||
}
|
||||
|
||||
if (started) {
|
||||
throw new Error('Application is already started.');
|
||||
}
|
||||
|
@ -349,10 +349,9 @@ export class iOSApplication implements iOSApplicationDefinition {
|
||||
}
|
||||
|
||||
/* tslint:disable */
|
||||
const iosApp = new iOSApplication();
|
||||
let iosApp: iOSApplication;
|
||||
/* tslint:enable */
|
||||
export { iosApp as ios };
|
||||
setApplication(iosApp);
|
||||
|
||||
// attach on global, so it can be overwritten in NativeScript Angular
|
||||
(<any>global).__onLiveSyncCore = function (context?: ModuleContext) {
|
||||
@ -389,6 +388,11 @@ export function getRootView() {
|
||||
|
||||
let started = false;
|
||||
export function run(entry?: string | NavigationEntry) {
|
||||
if (!iosApp) {
|
||||
iosApp = new iOSApplication();
|
||||
setApplication(iosApp);
|
||||
}
|
||||
|
||||
mainEntry = typeof entry === 'string' ? { moduleName: entry } : entry;
|
||||
started = true;
|
||||
|
||||
|
Reference in New Issue
Block a user