@@ -4,138 +4,18 @@ var Redux = require('redux');
4
4
5
5
var ReactRedux = require ( 'react-redux' ) ;
6
6
7
- function startsWithActionType ( actionForeign ) {
8
- var index = actionForeign . type . indexOf ( '@@PURESCRIPT_REACT_REDUX' ) ;
9
-
10
- return index === 0 ;
11
- }
12
-
13
- function makeActionForeign ( action ) {
14
- var constructorName = action . constructor && action . constructor . name ? action . constructor . name : 'UnknownConstructorName' ;
15
-
16
- var actionForeign = {
17
- type : '@@PURESCRIPT_REACT_REDUX/' + constructorName ,
18
- action : action
19
- } ;
20
-
21
- return actionForeign ;
22
- }
23
-
24
- exports . createStore_ = function createStore_ ( reducer , state , enhancer ) {
25
- return function ( ) {
26
- function reducerForeign ( stateReducerForeign , actionForeign ) {
27
- var result = startsWithActionType ( actionForeign ) ? reducer ( actionForeign . action ) ( stateReducerForeign ) : stateReducerForeign ;
28
-
29
- return result ;
30
- }
31
-
32
- function enhancerForeign ( createStoreForeign ) {
33
- return function ( reducerEnhancerForeign , stateEnhancerForeign ) {
34
- function createStore ( reducerCreateStore ) {
35
- return function ( stateCreateStore ) {
36
- return function ( ) {
37
- var result = createStoreForeign ( reducerCreateStore , stateCreateStore ) ;
38
-
39
- return result ;
40
- } ;
41
- } ;
42
- }
43
-
44
- return enhancer ( createStore ) ( reducerEnhancerForeign ) ( stateEnhancerForeign ) ( ) ;
45
- } ;
46
- }
47
-
48
- return Redux . createStore ( reducerForeign , state , enhancerForeign ) ;
49
- } ;
7
+ exports . reduxCreateStore = function reduxCreateStore ( reducer , state , enhancer ) {
8
+ return Redux . createStore ( reducer , state , enhancer ) ;
50
9
} ;
51
10
52
- exports . connect_ = function connect_ ( Tuple , mapStateToProps , reactClass ) {
53
- function mapStateToPropsForeign ( state , props ) {
54
- var statePropsTuple = Tuple ( state ) ( props ) ;
55
-
56
- var result = mapStateToProps ( statePropsTuple ) ;
57
-
58
- return result ;
59
- }
60
-
61
- return ReactRedux . connect ( mapStateToPropsForeign ) ( reactClass ) ;
11
+ exports . reduxApplyMiddleware = function reduxApplyMiddleware ( middleware ) {
12
+ return Redux . applyMiddleware . apply ( Redux , middleware ) ;
62
13
} ;
63
14
64
- exports . dispatch_ = function dispatch_ ( thisForeign , action ) {
65
- return function ( ) {
66
- var actionForeign = makeActionForeign ( action ) ;
67
-
68
- var actionForeignResult = thisForeign . props . dispatch ( actionForeign ) ;
69
-
70
- return actionForeignResult . action ;
71
- } ;
15
+ exports . reduxConnect = function reduxConnect ( mapStateToProps , mapDispatchToProps , mergeProps , options ) {
16
+ return ReactRedux . connect ( mapStateToProps , mapDispatchToProps , mergeProps , options ) ;
72
17
} ;
73
18
74
- exports . applyMiddleware = function applyMiddleware ( middlewares ) {
75
- var middlewaresForeign = middlewares . map ( function ( middleware ) {
76
- return function ( middlewareAPIForeign ) {
77
- function getState ( ) {
78
- return middlewareAPIForeign . getState ( ) ;
79
- }
80
-
81
- function dispatch ( action ) {
82
- return function ( ) {
83
- var actionForeignResult = makeActionForeign ( action ) ;
84
-
85
- var result = middlewareAPIForeign . dispatch ( actionForeignResult ) ;
86
-
87
- return result ;
88
- } ;
89
- }
90
-
91
- var cont = middleware ( { getState : getState , dispatch : dispatch } )
92
-
93
- return function ( nextForeign ) {
94
- return function ( actionForeign ) {
95
-
96
- function next ( action ) {
97
- return function ( ) {
98
- var actionForeignResult = makeActionForeign ( action ) ;
99
-
100
- var result = nextForeign ( actionForeignResult ) ;
101
-
102
- return result ;
103
- } ;
104
- }
105
-
106
- var action = actionForeign . action ;
107
-
108
- var result = cont ( next ) ( action ) ( ) ;
109
-
110
- return result ;
111
- } ;
112
- } ;
113
- }
114
- } ) ;
115
-
116
- var middlewareEnhancerForeign = Redux . applyMiddleware . apply ( Redux , middlewaresForeign ) ;
117
-
118
- var result = exports . fromEnhancerForeign ( middlewareEnhancerForeign ) ;
119
-
120
- return result ;
121
- } ;
122
-
123
- exports . fromEnhancerForeign = function fromEnhancerForeign ( enhancerForeign ) {
124
- return function ( createStore ) {
125
- return function ( reducerForeign ) {
126
- return function ( stateForeign ) {
127
- return function ( ) {
128
- function createStoreForeign ( reducer , state ) {
129
- var result = createStore ( reducer ) ( state ) ( ) ;
130
-
131
- return result ;
132
- } ;
133
-
134
- return enhancerForeign ( createStoreForeign ) ( reducerForeign , stateForeign ) ;
135
- } ;
136
- } ;
137
- } ;
138
- } ;
139
- }
19
+ exports . reduxConnect_ = exports . reduxConnect ;
140
20
141
- exports . providerClass = ReactRedux . Provider ;
21
+ exports . reduxProviderClass = ReactRedux . Provider ;
0 commit comments