@vslutov/redux-flux
Redux utils to remove bilerplate code
Install
npm install @vslutov/redux-flux
Code example
import { createFlux, applySelectors, bindActionCreators } from '@vslutov/redux-flux'
import { createStore, combineReducers } from 'redux'
const { setActions, themePropertiesReducer, defaultSelectors } = createFlux({
prefix: 'THEME_PROPERTIES',
defaultValues: {
fontSize: 8,
color: 'blue'
}
})
const store = createStore(combineReducers({
themeProperties: themePropertiesReducer
}))
t.is(defaultSelectors.fontSize(store.getState()), 8)
const actions = bindActionCreators(setActions, store.dispatch)
await actions.setFontSize(10)
t.is(defaultSelectors.fontSize(store.getState()), 10)
const prop = applySelectors(defaultSelectors)(store.getState())
t.deepEqual(prop, {
fontSize: 10,
color: 'blue'
})