/
eb
/
js-excel
Обзор
Документация
Войти
/
eb
/
js-excel
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/core/createStore.js
22 строки
523 B
Evgeniy Budaev
Finish redux and table logic
16 июн 2020, 10:52
16 июн 2020, 10:52
b7d4906
Код
Авторство
О чём код?
export function createStore(rootReducer, initialState = {}) { let state = rootReducer({...initialState}, {type: '__INIT__'}) let listeners = [] return { subscribe(fn) { listeners.push(fn) return { unsubscribe() { listeners = listeners.filter(l => l !== fn) } } }, dispatch(action) { state = rootReducer(state, action) listeners.forEach(listener => listener(state)) }, getState() { return JSON.parse(JSON.stringify(state)) } } }