File tree Expand file tree Collapse file tree 6 files changed +13
-13
lines changed
templates/KnockoutSpa/ClientApp Expand file tree Collapse file tree 6 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ const routes: Route[] = [
1212class AppRootViewModel {
1313 public route : KnockoutObservable < Route > ;
1414 private _router : Router ;
15-
15+
1616 constructor ( params : { history : HistoryModule . History } ) {
1717 // Activate the client-side router
1818 this . _router = new Router ( params . history , routes )
1919 this . route = this . _router . currentRoute ;
20-
20+
2121 // Load and register all the KO components needed to handle the routes
2222 // The optional 'bundle?lazy!' prefix is a Webpack feature that causes the referenced modules
2323 // to be split into separate files that are then loaded on demand.
@@ -27,12 +27,12 @@ class AppRootViewModel {
2727 ko . components . register ( 'counter-example' , require ( 'bundle?lazy!../counter-example/counter-example' ) ) ;
2828 ko . components . register ( 'fetch-data' , require ( 'bundle?lazy!../fetch-data/fetch-data' ) ) ;
2929 }
30-
30+
3131 // To support hot module replacement, this method unregisters the router and KO components.
3232 // In production scenarios where hot module replacement is disabled, this would not be invoked.
3333 public dispose ( ) {
3434 this . _router . dispose ( ) ;
35-
35+
3636 // TODO: Need a better API for this
3737 Object . getOwnPropertyNames ( ( < any > ko ) . components . _allRegisteredComponents ) . forEach ( componentName => {
3838 ko . components . unregister ( componentName ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import * as ko from 'knockout';
22
33class CounterExampleViewModel {
44 public currentCount = ko . observable ( 0 ) ;
5-
5+
66 public incrementCounter ( ) {
77 let prevCount = this . currentCount ( ) ;
88 this . currentCount ( prevCount + 1 ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ interface WeatherForecast {
99
1010class FetchDataViewModel {
1111 public forecasts = ko . observableArray < WeatherForecast > ( ) ;
12-
12+
1313 constructor ( ) {
1414 fetch ( '/api/SampleData/WeatherForecasts' )
1515 . then ( response => response . json ( ) )
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ interface NavMenuParams {
77
88class NavMenuViewModel {
99 public route : KnockoutObservable < Route > ;
10-
10+
1111 constructor ( params : NavMenuParams ) {
1212 // This viewmodel doesn't do anything except pass through the 'route' parameter to the view.
1313 // You could remove this viewmodel entirely, and define 'nav-menu' as a template-only component.
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export class Router {
1313 public currentRoute = ko . observable < Route > ( { } ) ;
1414 private disposeHistory : ( ) => void ;
1515 private clickEventListener : EventListener ;
16-
16+
1717 constructor ( history : HistoryModule . History , routes : Route [ ] ) {
1818 // Reset and configure Crossroads so it matches routes and updates this.currentRoute
1919 crossroads . removeAllRoutes ( ) ;
@@ -25,7 +25,7 @@ export class Router {
2525 } ) ;
2626 } ) ;
2727
28- // Make history.js watch for navigation and notify Crossroads
28+ // Make history.js watch for navigation and notify Crossroads
2929 this . disposeHistory = history . listen ( location => crossroads . parse ( location . pathname ) ) ;
3030 this . clickEventListener = evt => {
3131 let target : any = evt . target ;
@@ -37,10 +37,10 @@ export class Router {
3737 }
3838 }
3939 } ;
40-
40+
4141 document . addEventListener ( 'click' , this . clickEventListener ) ;
4242 }
43-
43+
4444 public dispose ( ) {
4545 this . disposeHistory ( ) ;
4646 document . removeEventListener ( 'click' , this . clickEventListener ) ;
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ ko.components.loaders.unshift({
99 if ( typeof componentConfig === 'function' ) {
1010 // It's a lazy-loaded Webpack bundle
1111 ( componentConfig as any ) ( loadedModule => {
12- // Handle TypeScript-style default exports
12+ // Handle TypeScript-style default exports
1313 if ( loadedModule . __esModule && loadedModule . default ) {
1414 loadedModule = loadedModule . default ;
1515 }
16-
16+
1717 // Pass the loaded module to KO's default loader
1818 ko . components . defaultLoader . loadComponent ( name , loadedModule , callback ) ;
1919 } ) ;
You can’t perform that action at this time.
0 commit comments