Migrate from hasher.js to history.js to support HTML5-style navigation. Also clean up the HMR support.

This commit is contained in:
SteveSandersonMS
2016-03-08 15:56:43 +00:00
parent bbdbb449d5
commit 515c659a47
14 changed files with 390 additions and 190 deletions

View File

@@ -2,22 +2,18 @@ import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.css';
import './css/site.css';
import * as ko from 'knockout';
import appLayout from './components/app-layout/app-layout';
import { createHistory } from 'history';
ko.components.register('app-layout', appLayout);
ko.applyBindings();
// Load and register the <app-root> component
ko.components.register('app-root', require('./components/app-root/app-root').default);
// Tell Knockout to start up an instance of your application
ko.applyBindings({ history: createHistory() });
// Basic hot reloading support. Automatically reloads and restarts the Knockout app each time
// you modify source files. This will not preserve any application state other than the URL.
declare var module: any;
if (module.hot) {
module.hot.dispose(() => {
ko.cleanNode(document.body);
// TODO: Need a better API for this
Object.getOwnPropertyNames((<any>ko).components._allRegisteredComponents).forEach(componentName => {
ko.components.unregister(componentName);
});
});
module.hot.accept();
module.hot.accept();
module.hot.dispose(() => ko.cleanNode(document.body));
}