mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor: improved core barrel exports and Application class (#10286)
BREAKING CHANGES:
`Application.orientation` is no longer a function.
Migration: Remove `()` from the `Application.orientation()` call:
```diff
import { Application } from "@nativescript/core";
-console.log(Application.orientation());
+console.log(Application.orientation);
```
`Application.systemAppearance` is no longer a function.
Migration: Remove `()` from the `Application.systemAppearance()` call:
```diff
import { Application } from "@nativescript/core";
-console.log(Application.systemAppearance());
+console.log(Application.systemAppearance);
```
This commit is contained in:
committed by
Nathan Walker
parent
963d0243de
commit
f64355ba7a
@@ -1,8 +1,8 @@
|
||||
import { Screen, Device } from '../platform';
|
||||
import * as appCommonModule from '../application/application-common';
|
||||
import { PlatformContext, findMatch, stripQualifiers } from './qualifier-matcher';
|
||||
import { registerModulesFromFileSystem } from './non-bundle-workflow-compat';
|
||||
import { Trace } from '../trace';
|
||||
import { Application } from '../application';
|
||||
|
||||
export type { PlatformContext } from './qualifier-matcher';
|
||||
|
||||
@@ -11,7 +11,12 @@ export type ModuleListProvider = () => string[];
|
||||
export class ModuleNameResolver {
|
||||
private _cache = {};
|
||||
|
||||
constructor(private context: PlatformContext, private moduleListProvider: ModuleListProvider = global.getRegisteredModules) {}
|
||||
constructor(private context: PlatformContext, private moduleListProvider: ModuleListProvider = global.getRegisteredModules) {
|
||||
Application.on('livesync', (args) => clearCache());
|
||||
Application.on('orientationChanged', (args) => {
|
||||
resolverInstance = undefined;
|
||||
});
|
||||
}
|
||||
|
||||
public resolveModuleName(path: string, ext: string): string {
|
||||
const key = path + ext;
|
||||
@@ -94,8 +99,3 @@ export function clearCache() {
|
||||
export function _setResolver(resolver: ModuleNameResolver) {
|
||||
resolverInstance = resolver;
|
||||
}
|
||||
|
||||
appCommonModule.on('livesync', (args) => clearCache());
|
||||
appCommonModule.on('orientationChanged', (args) => {
|
||||
resolverInstance = undefined;
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Application } from '../application';
|
||||
import * as fs from '../file-system';
|
||||
import * as appCommonModule from '../application/application-common';
|
||||
import { Trace } from '../trace';
|
||||
|
||||
const cache = new Set<string>();
|
||||
@@ -136,7 +136,7 @@ export function registerModulesFromFileSystem(moduleName: string) {
|
||||
|
||||
function initialize() {
|
||||
if (!initialized) {
|
||||
appCommonModule.on('livesync', (args) => cache.clear());
|
||||
Application.on('livesync', (args) => cache.clear());
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user