mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Reload app.css and clear file resolver cache on livesync.
This commit is contained in:
@@ -4,6 +4,7 @@ import fs = require("file-system");
|
||||
import styleScope = require("ui/styling/style-scope");
|
||||
import observable = require("data/observable");
|
||||
import frame = require("ui/frame");
|
||||
import fileResolverModule = require("file-system/file-name-resolver");
|
||||
|
||||
var events = new observable.Observable();
|
||||
global.moduleMerge(events, exports);
|
||||
@@ -53,5 +54,12 @@ export function loadCss() {
|
||||
}
|
||||
|
||||
global.__onLiveSync = function () {
|
||||
// Clear file resolver cache to respect newly added files.
|
||||
fileResolverModule.clearCache();
|
||||
|
||||
// Reload app.css in case it was changed.
|
||||
loadCss();
|
||||
|
||||
// Reload current page.
|
||||
frame.reloadPage();
|
||||
}
|
||||
2
file-system/file-name-resolver.d.ts
vendored
2
file-system/file-name-resolver.d.ts
vendored
@@ -12,9 +12,11 @@ declare module "file-system/file-name-resolver" {
|
||||
export class FileNameResolver {
|
||||
constructor(context: PlatformContext);
|
||||
resolveFileName(path: string, ext: string): string;
|
||||
clearCache(): void;
|
||||
}
|
||||
|
||||
export function resolveFileName(path: string, ext: string): string;
|
||||
export function clearCache(): void;
|
||||
|
||||
//@private
|
||||
export function findFileMatch(path: string, ext: string, candidates: Array<string>, context: PlatformContext): string
|
||||
|
||||
@@ -126,6 +126,10 @@ export class FileNameResolver implements definition.FileNameResolver {
|
||||
return result;
|
||||
}
|
||||
|
||||
public clearCache(): void {
|
||||
this._cache = {};
|
||||
}
|
||||
|
||||
private resolveFileNameImpl(path: string, ext: string): string {
|
||||
var result: string = null;
|
||||
path = fs.path.normalize(path);
|
||||
@@ -239,3 +243,8 @@ export function resolveFileName(path: string, ext: string): string {
|
||||
return resolverInstance.resolveFileName(path, ext);
|
||||
}
|
||||
|
||||
export function clearCache(): void {
|
||||
if (resolverInstance) {
|
||||
resolverInstance.clearCache();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user