@vslutov/redux-flux

0.2.3 • Public • Published

@vslutov/redux-flux

Build Status npm version Greenkeeper badge Coverage Status JavaScript Style Guide

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'
})

Package Sidebar

Install

npm i @vslutov/redux-flux

Weekly Downloads

0

Version

0.2.3

License

GPL-3.0-or-later

Unpacked Size

51.3 kB

Total Files

7

Last publish

Collaborators

  • vslutov