-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParent.js
54 lines (39 loc) · 926 Bytes
/
Parent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from 'react';
import { Record } from 'immutable';
import { Union } from 'results';
import Spindle, { Update } from '../../spindle';
import Counter from './Counter';
const Action = Union({
SetMin: null,
SetMax: null,
});
const Model = Record({
min: 0,
max: 0,
});
const init = () =>
Update({ model: Model() });
const update = (action, model) => Action.match(action, {
SetMin: v =>
Update({ model: model.set('min', v) }),
SetMax: v =>
Update({ model: model.set('max', v) }),
});
const view = (model, dispatch) => (
<div>
<p>min</p>
<Counter
onChange={dispatch.SetMin}
max={model.get('max')} />
<p>val</p>
<Counter
min={model.get('min')}
max={model.get('max')} />
<p>max</p>
<Counter
onChange={dispatch.SetMax}
min={model.get('min')} />
</div>
);
export default Spindle('Parent',
{ Action, init, update, view });