diff --git a/README.md b/README.md index 23a86b5..cea69cc 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,16 @@ }; ``` +3. (Optional) Set the initial value for the router state: + + ```ts + StoreModule.provideStore({ router: routerReducer }, { + router: { + path: window.location.pathname + window.location.search + } + }) + ``` + ### Dispatching Actions ```ts diff --git a/karma.conf.js b/karma.conf.js index 61cbf8b..ce17641 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,4 +1,5 @@ var path = require('path'); +var webpack = require('webpack'); module.exports = function(karma) { 'use strict'; @@ -41,28 +42,25 @@ module.exports = function(karma) { webpack: { devtool: 'inline-source-map', resolve: { - root: __dirname, - extensions: ['', '.ts', '.js'] + extensions: ['.ts', '.js'] }, module: { - preLoaders: [ + loaders: [ { + enforce: 'pre', test: /\.ts$/, loader: 'tslint-loader', exclude: [ /node_modules/ ] - } - ], - loaders: [ + }, { test: /\.ts?$/, exclude: /(node_modules)/, - loader: 'ts' - } - ], - postLoaders: [ + loader: 'awesome-typescript-loader' + }, { + enforce: 'post', test: /\.(js|ts)$/, loader: 'istanbul-instrumenter', include: path.resolve(__dirname, 'src'), exclude: [ @@ -72,11 +70,17 @@ module.exports = function(karma) { } ] }, - tslint: { - emitErrors: false, - failOnHint: false, - resourcePath: 'src' - } + plugins: [ + new webpack.LoaderOptionsPlugin({ + options: { + tslint: { + emitErrors: false, + failOnHint: false, + resourcePath: 'src' + } + } + }) + ] } }); }; diff --git a/package.json b/package.json index 82020e7..3c2c3fa 100644 --- a/package.json +++ b/package.json @@ -69,12 +69,11 @@ "rollup": "^0.34.13", "rxjs": "^5.0.0-beta.12", "source-map-loader": "^0.1.5", - "ts-loader": "^0.8.2", "tslint": "^3.15.1", "tslint-loader": "^2.1.5", "typescript": "^2.0.2", "uglifyjs": "^2.4.10", - "webpack": "^2.1.0-beta.21", + "webpack": "^2.1.0-beta.25", "zone.js": "^0.6.17" } } diff --git a/spec/reducer.spec.ts b/spec/reducer.spec.ts index ceebc07..10b4411 100644 --- a/spec/reducer.spec.ts +++ b/spec/reducer.spec.ts @@ -7,7 +7,7 @@ describe('routerReducer', function() { it('should have an initial state', function() { const action = { type: 'unknown' }; - expect(routerReducer(initialState, action)).toEqual({ path: null }); + expect(routerReducer(initialState, action)).toEqual({ path: '' }); }); it('should completely replace the state when a new location is pushed', function() { diff --git a/src/reducer.ts b/src/reducer.ts index 04997f4..6f391ae 100644 --- a/src/reducer.ts +++ b/src/reducer.ts @@ -6,7 +6,7 @@ export interface RouterState { } export const initialState: RouterState = { - path: null + path: '' }; export function routerReducer(state: RouterState = initialState, action: Action): RouterState {