-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
52 lines (42 loc) · 1.03 KB
/
index.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
import {run} from '@cycle/run';
import {makeDOMDriver, div} from '@cycle/dom';
import xs from 'xstream';
import Scratchpad from './src/scratchpad';
const startingCode = `
import {run} from '@cycle/run';
import {makeDOMDriver, div, button} from '@cycle/dom';
import _ from 'lodash';
import xs from 'xstream';
function main (sources) {
const add$ = sources.DOM
.select('.add')
.events('click')
.map(ev => 1);
const count$ = add$.fold((total, change) => total + change, 0);
return {
DOM: count$.map(count =>
div('.counter', [
'Count: ' + count,
button('.add', 'Add')
])
)
};
}
const drivers = {
DOM: makeDOMDriver('.app')
}
// Normally you need to call run, but Tricycle handles that for you!
// If you want to try this out locally, just uncomment this code.
//
// run(main, drivers);
`;
function main ({DOM}) {
const props = xs.of({code: startingCode});
const scratchpad = Scratchpad(DOM, props);
return {
DOM: scratchpad.DOM
};
}
run(main, {
DOM: makeDOMDriver('.tricycle')
});