File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed
Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 11import { Action } from '@app/store'
22
33export const applyReducers =
4- < T > ( ...reducers : Array < ( state : T , action : Action < never > ) => T > ) =>
5- ( state : T , action : Action < never > ) : T =>
6- reducers . reduce ( ( a : any , b : any ) => a ( b ( state , action ) , action ) ) as any
4+ < T > ( ...reducers : Array < ( state : T , action : Action < any > ) => T > ) =>
5+ ( state : T , action : Action < any > ) : T => {
6+ let st = state
7+
8+ for ( const reducer of reducers ) {
9+ st = reducer ( st , action )
10+ }
11+
12+ return st
13+ }
714
815export const actionIs =
916 ( type : string ) =>
10- ( action : Action < never > ) : boolean =>
17+ ( action : Action < any > ) : boolean =>
1118 type === action ?. type
1219
1320export const onlyWhen =
14- ( predicate : ( action : Action < never > ) => boolean , defaultState : any = { } ) =>
15- ( reducer : ( state : any , action : Action < never > ) => any ) =>
16- ( state : any = { } , action : Action < never > ) : any => {
17- if ( typeof state === 'undefined' ) {
21+ ( predicate : ( action : Action < any > ) => boolean , defaultState : any = { } ) =>
22+ ( reducer : ( state : any , action : Action < any > ) => any ) =>
23+ ( state : any , action : Action < any > ) : any => {
24+ if ( state === null || typeof state === 'undefined' ) {
1825 return defaultState
1926 }
2027
You can’t perform that action at this time.
0 commit comments