-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesign4.js
78 lines (61 loc) · 1.39 KB
/
design4.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const name = S('Harry'),
surname = S('Potter');
any((name, surname) => {
document.title = `${name} ${surname}`;
}, [name, surname]);
const width = S(window.innerWidth);
effect(() => {
const handleResize = () => width(window.innerWidth);
window.addEventListener('resize', handleResize);
return () => {
window.removeEventListener('resize', handleResize);
};
});
any(() => render(
<Card>
<Row label="Name">
<Input value={ name() } onChange={ name } />
</Row>
<Row label="Surname">
<Input value={ surname() } onChange={ surname } />
</Row>
<Row label="Width">
<Text>{ width() }</Text>
</Row>
</Card>
), [name, surname, width]);
////
const payload = S();
render(<Component onSubmit={ payload });
yield payload;
payload().field = 'somevalue';
const request = send('http/url', payload());
yield waitAtLeast(500, request);
yield render('');
window.scrollTo(0,0);
return toApp;
////
const S = () => {
const callbacks = [];
let value;
const result = v => {
if (v !== undefined) {
value = v;
callbacks.forEach(fn => fn(v));
return;
}
return value;
};
result.then = fn => callbacks.push(fn);
return result;
};
const name = S();
const surname = S();
const run = async () => {
await name;
await surname;
};
////
let resolve;
const p = new Promise(r => resolve = r);
p.then(v => console.log(`My value = ${v}`));