Reload app.css and clear file resolver cache on livesync.

This commit is contained in:
vakrilov
2015-11-10 15:00:41 +02:00
parent 87e064c417
commit 5f07f4fc17
3 changed files with 19 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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();
}
}