You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
555 B
29 lines
555 B
export function DefaultReducer(key, initialState = {}) { |
|
return (state = initialState, {type = '', payload = {}}) => { |
|
switch (type) { |
|
case key: |
|
return {...state, ...payload}; |
|
} |
|
return state; |
|
}; |
|
} |
|
|
|
export function buildAction(id) { |
|
return function(payload) { |
|
return { |
|
type: id, |
|
payload: payload, |
|
}; |
|
}; |
|
} |
|
|
|
export function buildActionForKey(id, key) { |
|
return function(payload) { |
|
let result = { |
|
type: id, |
|
payload: {}, |
|
}; |
|
result.payload[key] = payload; |
|
return result; |
|
}; |
|
}
|
|
|