@@ -15,9 +15,7 @@ type UISpec props = forall r.
15
15
16
16
type StatefulRender props state = Eff (p :: ReactProps props , r :: ReadReactState state ) UI
17
17
type StatefulUISpec props state = forall a r .
18
- { render :: StatefulRender props state
19
- , getInitialState :: { } -> state
20
- , componentWillMount :: { } -> { }
18
+ { componentWillMount :: { } -> { }
21
19
, componentDidMount :: { } -> { }
22
20
, componentWillReceiveProps :: props -> { }
23
21
, shouldComponentUpdate :: props -> state -> Boolean
@@ -27,9 +25,7 @@ type StatefulUISpec props state = forall a r.
27
25
}
28
26
29
27
defaultStatefulSpec =
30
- { render: defaultRender
31
- , getInitialState: \_ -> {}
32
- , componentWillMount: \_ -> {}
28
+ { componentWillMount: \_ -> {}
33
29
, componentDidMount: \_ -> {}
34
30
, componentWillReceiveProps: \_ -> {}
35
31
, shouldComponentUpdate: \_ _ -> true
@@ -38,51 +34,48 @@ defaultStatefulSpec =
38
34
, componentWillUnmount: \_ -> {}
39
35
}
40
36
41
- foreign import defaultRender
42
- " function defaultRender() { \
43
- \ return React.DOM.p({}); \
44
- \ }"
45
- :: forall props state . StatefulRender props state
46
-
47
37
foreign import mkUI
48
- " function mkUI(render) { \
49
- \ return React.createClass({ \
50
- \ render: function() { \
51
- \ __current = this; \
52
- \ try { \
53
- \ var ui = render(); \
54
- \ } finally { \
55
- \ __current = null; \
56
- \ } \
57
- \ return ui; \
58
- \ } \
59
- \ }); \
38
+ " function mkUI(render) { \
39
+ \ return React.createClass({ \
40
+ \ render: function() { \
41
+ \ __current = this; \
42
+ \ try { \
43
+ \ var ui = render(); \
44
+ \ } finally { \
45
+ \ __current = null; \
46
+ \ } \
47
+ \ return ui; \
48
+ \ } \
49
+ \ }); \
60
50
\ }"
61
51
:: forall props .
62
52
Render props
63
53
-> (props -> UI )
64
54
65
55
foreign import mkUIFromSpec
66
- " function mkUIFromSpec(ps) { \
67
- \ var props = {}; \
68
- \ for (var p in ps) { \
69
- \ if (ps.hasOwnProperty(p)) { \
70
- \ props[p] = ps[p]; \
71
- \ } \
72
- \ } \
73
- \ props.render = function() { \
74
- \ __current = this; \
75
- \ try { \
76
- \ var ui = ps.render(); \
77
- \ } finally { \
78
- \ __current = null; \
79
- \ } \
80
- \ return ui; \
81
- \ }; \
82
- \ return React.createClass(props); \
56
+ " function mkUIFromSpec(render) { \
57
+ \ return function(ss) { \
58
+ \ var props = {}; \
59
+ \ for (var p in ps) { \
60
+ \ if (ps.hasOwnProperty(p)) { \
61
+ \ props[p] = ps[p]; \
62
+ \ } \
63
+ \ } \
64
+ \ props.render = function() { \
65
+ \ __current = this; \
66
+ \ try { \
67
+ \ var ui = render(); \
68
+ \ } finally { \
69
+ \ __current = null; \
70
+ \ } \
71
+ \ return ui; \
72
+ \ }; \
73
+ \ return React.createClass(props); \
74
+ \ }; \
83
75
\ }"
84
76
:: forall props .
85
- UISpec props
77
+ Render props
78
+ -> UISpec props
86
79
-> (props -> UI )
87
80
88
81
foreign import getProps
@@ -120,27 +113,36 @@ foreign import mkStatefulUI
120
113
-> (props -> UI )
121
114
122
115
foreign import mkStatefulUIFromSpec
123
- " var __current; \
124
- \ function mkStatefulUIFromSpec(ss) { \
125
- \ var specs = {}; \
126
- \ for (var s in ss) { \
127
- \ if (ss.hasOwnProperty(s)) { \
128
- \ specs[s] = ss[s]; \
129
- \ } \
130
- \ } \
131
- \ specs.render = function() { \
132
- \ __current = this; \
133
- \ try { \
134
- \ var ui = ss.render(); \
135
- \ } finally { \
136
- \ __current = null; \
137
- \ } \
138
- \ return ui; \
139
- \ }; \
140
- \ return React.createClass(specs); \
116
+ " var __current; \
117
+ \ function mkStatefulUIFromSpec(state) { \
118
+ \ return function(render) { \
119
+ \ return function (ss) { \
120
+ \ var specs = {}; \
121
+ \ for (var s in ss) { \
122
+ \ if (ss.hasOwnProperty(s)) { \
123
+ \ specs[s] = ss[s]; \
124
+ \ } \
125
+ \ } \
126
+ \ specs.getInitialState = function() { \
127
+ \ return state; \
128
+ \ }; \
129
+ \ specs.render = function() { \
130
+ \ __current = this; \
131
+ \ try { \
132
+ \ var ui = render(); \
133
+ \ } finally { \
134
+ \ __current = null; \
135
+ \ } \
136
+ \ return ui; \
137
+ \ }; \
138
+ \ return React.createClass(specs); \
139
+ \ } \
140
+ \ } \
141
141
\ }"
142
142
:: forall props state .
143
- StatefulUISpec props state
143
+ state
144
+ -> StatefulRender props state
145
+ -> StatefulUISpec props state
144
146
-> (props -> UI )
145
147
146
148
foreign import writeState
0 commit comments