File tree Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { SUCCESS_COUNT , COUNT } from './actionTypes'
2
+ import { combineReducers } from 'recost'
2
3
3
- export default ( state , action ) => {
4
- if ( action . type === SUCCESS_COUNT || action . type === COUNT ) {
4
+ const reducerOne = ( state , action ) => {
5
+ if ( action . type === SUCCESS_COUNT ) {
5
6
return {
6
7
...state ,
7
8
count : state . count + 1
@@ -10,3 +11,16 @@ export default (state, action) => {
10
11
11
12
return state
12
13
}
14
+
15
+ const reducerTwo = ( state , action ) => {
16
+ if ( action . type === COUNT ) {
17
+ return {
18
+ ...state ,
19
+ count : state . count + 1
20
+ }
21
+ }
22
+
23
+ return state
24
+ }
25
+
26
+ export default combineReducers ( [ reducerOne , reducerTwo ] )
Original file line number Diff line number Diff line change 2
2
"name" : " recost" ,
3
3
"version" : " 0.0.2" ,
4
4
"main" : " lib/index.js" ,
5
- "repository" : " git@github.com:JWebCoder/recost.git" ,
5
+ "repository" : {
6
+ "type" : " git" ,
7
+ "url" : " git+https://github.com/JWebCoder/recost.git"
8
+ },
6
9
"keywords" : [
7
10
" js" ,
8
11
" react" ,
Original file line number Diff line number Diff line change @@ -18,12 +18,25 @@ let dispatch = () => {
18
18
console . warn ( 'Still no context created' )
19
19
}
20
20
21
+ let combineReducers = ( reducers ) => {
22
+ return function ( state , action ) {
23
+ let newState = state
24
+ reducers . forEach (
25
+ function ( reducer ) {
26
+ newState = reducer ( newState , action )
27
+ }
28
+ )
29
+ return newState
30
+ }
31
+ }
32
+
21
33
export {
22
34
Context ,
23
35
Consumer ,
24
36
Provider ,
25
37
withState ,
26
- dispatch
38
+ dispatch ,
39
+ combineReducers
27
40
}
28
41
29
42
const initContext = ( initialState = { } , reducer , middleware = [ ] ) => {
You can’t perform that action at this time.
0 commit comments