0.6.1 • Published 9 years ago

refinery-js v0.6.1

Weekly downloads
74
License
-
Repository
github
Last release
9 years ago

refinery

wercker status dependency status code coverage npm version

Reactive Redux reducer

Let you build your application state as small reducer with dependency relations.

usage

// fragment the state, declare a reducer for each

// this fragment is updated when an action is dispatched
const A = ( action, a = 0 ) => {
    if ( 'A:increment' == action.type )
        return a + 1
    
    else
        return a
}
A.source    = true

// this one too
const B = ( action, b = 0 ) => {
    if ( 'B:increment' == action.type )
        return b + 1
    
    else
        return b
}
B.source    = true

// this fragment depends on others, it is updated when the dependencies change
const sum => ( a, b ) =>
    a + b
sum.dependencies = [ A, B ]
// usage with redux

import createReducer     from 'refinery-js'
import { createStore }   from 'redux'

// create the reducer from the fragments
const { reduce, initState } = createReducer( { A, B, sum } )

// create redux store
const store = createStore( reduce, initState )

store.dispatch({type:'A:increment'})

store.getState()
// {
//      A   : 1
//      B   : 0
//      sum : 1
// }
0.6.1

9 years ago

0.6.0

9 years ago

0.5.6

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.0

9 years ago

0.4.8

10 years ago

0.4.7

10 years ago

0.4.6

10 years ago

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago