All files / src enhance.js

100% Statements 6/6
100% Branches 3/3
100% Functions 3/3
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26    3x 2x           7x   7x   7x                        
import {mapKeys, mergePlainObject} from './util'
 
const defaultReducer = {
    "@@mergeState": (state, action) => ({...state, ...action.payload})
}
 
 
export default function (model) {
 
    const {namespace, initialState = {}, reducers = {}, effects = {}} = model
 
    const _status = mapKeys(effects).map(key => ({[`${key}Status`]: false})).reduce(mergePlainObject, {})
 
    return ({
        namespace, effects,
        initialState: {
            ...initialState,
            "@@status": _status
        },
        reducers: {
            ...reducers,
            ...defaultReducer
        },
    })
 
}