diff --git a/templates/KnockoutSpa/ClientApp/components/app-root/app-root.ts b/templates/KnockoutSpa/ClientApp/components/app-root/app-root.ts index 2d05cb1..7583faf 100644 --- a/templates/KnockoutSpa/ClientApp/components/app-root/app-root.ts +++ b/templates/KnockoutSpa/ClientApp/components/app-root/app-root.ts @@ -12,12 +12,12 @@ const routes: Route[] = [ class AppRootViewModel { public route: KnockoutObservable; private _router: Router; - + constructor(params: { history: HistoryModule.History }) { // Activate the client-side router this._router = new Router(params.history, routes) this.route = this._router.currentRoute; - + // Load and register all the KO components needed to handle the routes // The optional 'bundle?lazy!' prefix is a Webpack feature that causes the referenced modules // to be split into separate files that are then loaded on demand. @@ -27,12 +27,12 @@ class AppRootViewModel { ko.components.register('counter-example', require('bundle?lazy!../counter-example/counter-example')); ko.components.register('fetch-data', require('bundle?lazy!../fetch-data/fetch-data')); } - + // To support hot module replacement, this method unregisters the router and KO components. // In production scenarios where hot module replacement is disabled, this would not be invoked. public dispose() { this._router.dispose(); - + // TODO: Need a better API for this Object.getOwnPropertyNames((ko).components._allRegisteredComponents).forEach(componentName => { ko.components.unregister(componentName); diff --git a/templates/KnockoutSpa/ClientApp/components/counter-example/counter-example.ts b/templates/KnockoutSpa/ClientApp/components/counter-example/counter-example.ts index b056ed2..39b7f04 100644 --- a/templates/KnockoutSpa/ClientApp/components/counter-example/counter-example.ts +++ b/templates/KnockoutSpa/ClientApp/components/counter-example/counter-example.ts @@ -2,7 +2,7 @@ import * as ko from 'knockout'; class CounterExampleViewModel { public currentCount = ko.observable(0); - + public incrementCounter() { let prevCount = this.currentCount(); this.currentCount(prevCount + 1); diff --git a/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts b/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts index cfa71e4..deab068 100644 --- a/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts +++ b/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts @@ -9,7 +9,7 @@ interface WeatherForecast { class FetchDataViewModel { public forecasts = ko.observableArray(); - + constructor() { fetch('/api/SampleData/WeatherForecasts') .then(response => response.json()) diff --git a/templates/KnockoutSpa/ClientApp/components/nav-menu/nav-menu.ts b/templates/KnockoutSpa/ClientApp/components/nav-menu/nav-menu.ts index ffd476a..186c60e 100644 --- a/templates/KnockoutSpa/ClientApp/components/nav-menu/nav-menu.ts +++ b/templates/KnockoutSpa/ClientApp/components/nav-menu/nav-menu.ts @@ -7,7 +7,7 @@ interface NavMenuParams { class NavMenuViewModel { public route: KnockoutObservable; - + constructor(params: NavMenuParams) { // This viewmodel doesn't do anything except pass through the 'route' parameter to the view. // You could remove this viewmodel entirely, and define 'nav-menu' as a template-only component. diff --git a/templates/KnockoutSpa/ClientApp/router.ts b/templates/KnockoutSpa/ClientApp/router.ts index 6162edd..526394e 100644 --- a/templates/KnockoutSpa/ClientApp/router.ts +++ b/templates/KnockoutSpa/ClientApp/router.ts @@ -13,7 +13,7 @@ export class Router { public currentRoute = ko.observable({}); private disposeHistory: () => void; private clickEventListener: EventListener; - + constructor(history: HistoryModule.History, routes: Route[]) { // Reset and configure Crossroads so it matches routes and updates this.currentRoute crossroads.removeAllRoutes(); @@ -25,7 +25,7 @@ export class Router { }); }); - // Make history.js watch for navigation and notify Crossroads + // Make history.js watch for navigation and notify Crossroads this.disposeHistory = history.listen(location => crossroads.parse(location.pathname)); this.clickEventListener = evt => { let target: any = evt.target; @@ -37,10 +37,10 @@ export class Router { } } }; - + document.addEventListener('click', this.clickEventListener); } - + public dispose() { this.disposeHistory(); document.removeEventListener('click', this.clickEventListener); diff --git a/templates/KnockoutSpa/ClientApp/webpack-component-loader.ts b/templates/KnockoutSpa/ClientApp/webpack-component-loader.ts index d46ec82..10f13e8 100644 --- a/templates/KnockoutSpa/ClientApp/webpack-component-loader.ts +++ b/templates/KnockoutSpa/ClientApp/webpack-component-loader.ts @@ -9,11 +9,11 @@ ko.components.loaders.unshift({ if (typeof componentConfig === 'function') { // It's a lazy-loaded Webpack bundle (componentConfig as any)(loadedModule => { - // Handle TypeScript-style default exports + // Handle TypeScript-style default exports if (loadedModule.__esModule && loadedModule.default) { loadedModule = loadedModule.default; } - + // Pass the loaded module to KO's default loader ko.components.defaultLoader.loadComponent(name, loadedModule, callback); });