mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
Modal
This commit is contained in:
parent
132fe872b6
commit
e5bc0d258f
17 changed files with 301 additions and 65 deletions
19
src/utils/reducer.ts
Normal file
19
src/utils/reducer.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
// create-reducer.ts
|
||||
import { Action } from 'redux';
|
||||
|
||||
type Handlers<State, Types extends string, Actions extends Action<Types>> = {
|
||||
readonly [Type in Types]: (state: State, action: Actions) => State
|
||||
}
|
||||
|
||||
// export const createReducer = <State, Types extends string, Actions extends Action<Types>>(
|
||||
// initialState: State,
|
||||
// handlers: Handlers<State, Types, Actions>,
|
||||
// ) => (state = initialState, action: Actions) =>
|
||||
// handlers.hasOwnProperty(action.type) ? handlers[action.type as Types](state, action) : state;
|
||||
|
||||
export const createReducer = (
|
||||
initialState,
|
||||
handlers,
|
||||
) => (state = initialState, action) => handlers.hasOwnProperty(action.type)
|
||||
? handlers[action.type](state, action)
|
||||
: state;
|
Loading…
Add table
Add a link
Reference in a new issue