UNPKG

ttk-app-core

Version:
35 lines (28 loc) 923 B
import { Map, List, fromJS } from 'immutable' import { reducer as MetaReducer } from 'edf-meta-engine' import { getInitState } from './data' class reducer { constructor(option) { this.metaReducer = option.metaReducer } init = (state) => { return this.metaReducer.init(state, getInitState()) } load = (state, option) => { state = this.metaReducer.sf(state, 'data.list', fromJS(option)) return state } updatefile = (state, item) => { state = this.metaReducer.sf(state, item.path, fromJS(item.value)) return state } update = (state, option) => { state = this.metaReducer.sfs(state, option) return state } } export default function creator(option) { const metaReducer = new MetaReducer(option), o = new reducer({ ...option, metaReducer }) return { ...metaReducer, ...o } }