Skip to content

connnect is now **composable**

Compare
Choose a tag to compare
@jcouyang jcouyang released this 22 Nov 13:50
· 350 commits to master since this release
901cf9e
  • connect will return a composable wrapper component
let wrapper1 = connect(i=>({inc1: ()=>({type: 'inc'})}))
let wrapper2 = connect(i=>({inc2: ()=>({type: 'inc2'})}))
wrapper1(wrapper2(CounterView))
// wrapper are simply function, so you can
let wrapper = R.compose(wrapper1, wrapper2)
wrapper(CounterView)
  • useactions as default field to define actions
    const Counter = connect(intent$=>{
      return {
        sink$: intent$.map(...),
        inc: ()=>({type:'inc'}),    // <--  these are actions, 
        dec: ()=>({type:'dec'}),  // <--  if it confuse you why they're same level with sink$
        actions: {                        // <-- now you can put all actions inside `actions` field
          inc3: ()=>({type: 'inc3'}) 
        },
      }
    })(CounterView)