Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

fix(reducer): Added non-null value for initial state path #27

Merged
merged 1 commit into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 19 additions & 15 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var path = require('path');
var webpack = require('webpack');

module.exports = function(karma) {
'use strict';
Expand Down Expand Up @@ -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: [
Expand All @@ -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'
}
}
})
]
}
});
};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion spec/reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface RouterState {
}

export const initialState: RouterState = {
path: null
path: ''
};

export function routerReducer(state: RouterState = initialState, action: Action): RouterState {
Expand Down