0.6.1 • Published 7 years ago

refinery-js v0.6.1

Weekly downloads
74
License
-
Repository
github
Last release
7 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

7 years ago

0.6.0

7 years ago

0.5.6

7 years ago

0.5.5

8 years ago

0.5.4

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.0

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago