@@ -6,13 +6,6 @@ module React.Redux
6
6
, Enhancer
7
7
, Enhancer_
8
8
, Store
9
- , createClass
10
- , createProviderElement
11
- , createElement
12
- , createStore
13
- , createStore'
14
- , reducerOptic
15
-
16
9
, Spec
17
10
, Render
18
11
, GetInitialState
@@ -23,11 +16,17 @@ module React.Redux
23
16
, ComponentWillUpdate
24
17
, ComponentDidUpdate
25
18
, ComponentWillUnmount
19
+ , createClass
20
+ , createProviderElement
21
+ , createElement
22
+ , createStore
23
+ , createStore'
24
+ , reducerOptic
26
25
, spec
27
26
, spec'
28
27
) where
29
28
30
- import Prelude (Unit , (<<<), (>>=), const , pure , id , unit )
29
+ import Prelude (Unit , (<<<), (>>=), (<$), const , pure , id , unit )
31
30
32
31
import Control.Monad.Eff (Eff )
33
32
import Control.Monad.Eff.Class (class MonadEff , liftEff )
@@ -100,8 +99,8 @@ spec getInitialState render =
100
99
spec' :: forall props eff f action . Render props Unit eff f action -> Spec props Unit eff f action
101
100
spec' = spec (\_ _ -> pure unit)
102
101
103
- createClass :: forall props state eff f action state' . MonadEff (Effects eff ) f => Getter' state' props -> Spec props state eff f action -> ReduxReactClass state' props
104
- createClass lens spec_ = connect (view lens ) reactClass
102
+ createClass :: forall props state eff f action action' state' . MonadEff (Effects eff ) f => Getter' action' action -> Getter' state' props -> Spec props state eff f action' -> ReduxReactClass state' props
103
+ createClass actionLens stateLens spec_ = connect (view stateLens ) reactClass
105
104
where
106
105
reactClass :: React.ReactClass props
107
106
reactClass =
@@ -117,8 +116,8 @@ createClass lens spec_ = connect (view lens) reactClass
117
116
, componentWillUnmount: \this -> spec_.componentWillUnmount (dispatch this) this
118
117
}
119
118
where
120
- dispatch :: React.ReactThis props state -> f action -> f action
121
- dispatch this action = action >>= liftEff <<< runFn2 dispatch_ this
119
+ dispatch :: React.ReactThis props state -> f action' -> f action'
120
+ dispatch this action' = action' >>= \a -> a <$ liftEff ( runFn2 dispatch_ this (view actionLens a))
122
121
123
122
createProviderElement :: forall props action state' . Store action state' -> ReduxReactClass state' props -> React.ReactElement
124
123
createProviderElement store reduxClass = React .createElement providerClass { store: store } [ createElement reduxClass ]
0 commit comments