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);
|
on(event: 'activityRequestPermissions', callback: (args: AndroidActivityRequestPermissionsEventData) => void, thisArg?: any);
|
||||||
}
|
}
|
||||||
|
|
||||||
const androidApp = new AndroidApplication();
|
let androidApp: AndroidApplication;
|
||||||
export { androidApp as android };
|
export { androidApp as android };
|
||||||
appCommon.setApplication(androidApp);
|
|
||||||
|
|
||||||
let mainEntry: NavigationEntry;
|
let mainEntry: NavigationEntry;
|
||||||
let started = false;
|
let started = false;
|
||||||
|
|
||||||
export function run(entry?: NavigationEntry | string) {
|
export function run(entry?: NavigationEntry | string) {
|
||||||
|
if (!androidApp) {
|
||||||
|
androidApp = new AndroidApplication();
|
||||||
|
appCommon.setApplication(androidApp);
|
||||||
|
}
|
||||||
|
|
||||||
if (started) {
|
if (started) {
|
||||||
throw new Error('Application is already started.');
|
throw new Error('Application is already started.');
|
||||||
}
|
}
|
||||||
|
@ -349,10 +349,9 @@ export class iOSApplication implements iOSApplicationDefinition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
const iosApp = new iOSApplication();
|
let iosApp: iOSApplication;
|
||||||
/* tslint:enable */
|
/* tslint:enable */
|
||||||
export { iosApp as ios };
|
export { iosApp as ios };
|
||||||
setApplication(iosApp);
|
|
||||||
|
|
||||||
// attach on global, so it can be overwritten in NativeScript Angular
|
// attach on global, so it can be overwritten in NativeScript Angular
|
||||||
(<any>global).__onLiveSyncCore = function (context?: ModuleContext) {
|
(<any>global).__onLiveSyncCore = function (context?: ModuleContext) {
|
||||||
@ -389,6 +388,11 @@ export function getRootView() {
|
|||||||
|
|
||||||
let started = false;
|
let started = false;
|
||||||
export function run(entry?: string | NavigationEntry) {
|
export function run(entry?: string | NavigationEntry) {
|
||||||
|
if (!iosApp) {
|
||||||
|
iosApp = new iOSApplication();
|
||||||
|
setApplication(iosApp);
|
||||||
|
}
|
||||||
|
|
||||||
mainEntry = typeof entry === 'string' ? { moduleName: entry } : entry;
|
mainEntry = typeof entry === 'string' ? { moduleName: entry } : entry;
|
||||||
started = true;
|
started = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user