Skip to content

freeman-lab/minidux

Repository files navigation

minidux

just like redux but tiny

This little module mimics the redux API, is written in vanilla JS, and has minimal dependencies and dev dependencies.

Redux docs

Because this module aims to be a drop-in replacement for redux, you can read the redux docs for detailed usage examples and API reference.

Usage

Usage of minidux is identical to redux:

var createStore = require('minidux').createStore

function reducer (state, action) {
  if (action.type === 'example') {
    return { example: true }
  }
}

var store = createStore(reducer, {
  example: false
})

store.subscribe(function (state) {
  console.log(state)
})

store.dispatch({ type: 'example' })

Requiring modules

If you'd like to use applyMiddleware, bindActionCreators, combineReducers, createStore, & compose separately, you can require those files directly:

var applyMiddleware = require('minidux/applyMiddleware')
var bindActionCreators = require('minidux/bindActionCreators')
var combineReducers = require('minidux/combineReducers')
var createStore = require('minidux/createStore')
var compose = require('minidux/compose')

API

var store = createStore(reducer, [initialState], [enhancer])

Full redux docs for createStore

store.getState()

Full redux docs for store.getState

store.dispatch(action)

Full redux docs for store.dispatch

store.subscribe(listener)

Full redux docs for store.subscribe

store.replaceReducer(nextReducer)

Full redux docs for store.replaceReducer

combineReducers(reducers)

Full redux docs for combineReducers

applyMiddleware(...middlewares)

Full redux docs for applyMiddleware

bindActionCreators(actionCreators, dispatch)

Full redux docs for bindActionCreators

compose(...functions)

Full redux docs for compose

Instead of implementing another compose function we use the [composite](http://npmjs.com/composite) module.

Issues

Notice any incompatibilites with redux? Let us know in the issues queue.

See also

  • hxdx – connects a redux-style store to a virtual-dom-style view
  • send-action – a state container with an API that is much simpler than redux, but that follows a similar pattern
  • store-emitter – a state container with an API similar to redux with more flexible options for listening to changes
  • prior art – some of the projects that redux is based on

License

MIT

About

just like redux but tiny

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published