Skip to content

Commit 6f390aa

Browse files
committed
Setup reducer properly
1 parent c8e9940 commit 6f390aa

File tree

6 files changed

+12
-41
lines changed

6 files changed

+12
-41
lines changed

package-lock.json

-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
},
1313
"private": true,
1414
"dependencies": {
15-
"@angular-redux/form": "6.1.1",
1615
"@angular-redux/store": "6.1.0",
1716
"@angular/animations": "4.0.0",
1817
"@angular/common": "4.0.0",

src/app/app.state.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11

22
import { combineReducers } from 'redux';
3-
import { composeReducers } from '@angular-redux/form/dist/source';
43
import { hoverflyReducer } from './shared/reducers/hoverfly.reducer';
54
export interface AppState {
65
hoverfly
76
}
87

9-
export const rootReducer = composeReducers(
10-
combineReducers<AppState>({
11-
hoverfly: hoverflyReducer,
12-
}), (state, action) => {
13-
return state;
14-
}
15-
);
8+
export const rootReducer = combineReducers<AppState>({
9+
hoverfly: hoverflyReducer,
10+
});
1611

1712
export const enhancers = [];

src/app/shared/reducers/create-reducer.ts

-13
This file was deleted.

src/app/shared/reducers/hoverfly.reducer.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
import { hoverflyReducer } from './hoverfly.reducer';
4-
import { fromJS } from 'immutable';
4+
import { Map, fromJS } from 'immutable';
55
import { HOVERFLY_ACTIONS } from '../services/hoverfly.service';
66

77
const INITIAL_STATE: Map<any, any> = fromJS({
+8-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
import { Hoverfly } from '../models/hoverfly.model';
2-
import { createReducer } from './create-reducer';
31
import { fromJS, Map } from 'immutable';
42
import { HOVERFLY_ACTIONS } from '../services/hoverfly.service';
53

6-
export interface HoverflyState {
7-
hoverfly: Hoverfly;
8-
}
9-
104
const INITIAL_STATE: Map<any, any> = fromJS({
115
hoverfly: {}
126
});
137

14-
export const hoverflyReducer = createReducer(INITIAL_STATE, {
8+
export const hoverflyReducer = (state = INITIAL_STATE, action) => {
159

16-
[HOVERFLY_ACTIONS.UPDATE]: (state: Map<any, any>, action) =>
10+
switch (action.type) {
1711

18-
state.update('hoverfly', (hoverfly: Map<any, any>) => hoverfly.merge(fromJS(action.payload)))
12+
case HOVERFLY_ACTIONS.UPDATE:
13+
return state.update('hoverfly', (hoverfly: Map<any, any>) => hoverfly.merge(fromJS(action.payload)));
1914

20-
});
15+
default:
16+
return state;
17+
}
18+
};

0 commit comments

Comments
 (0)