-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
50 lines (43 loc) · 1.33 KB
/
index.html
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
<!doctype html>
<html>
<head>
<title>Vulture Example: Simple Counter</title>
<script src="https://npmcdn.com/[email protected]/zen-observable.js"></script>
<script src="../../build/dist/vulture.js"></script>
</head>
<body>
<div id="app"></div>
<script>
var count = 0
var observers = []
function increment () {
count += 1
observers.forEach(function observerNext (observer) { observer.next(count) })
}
function decrement () {
count -= 1
observers.forEach(function observerNext (observer) { observer.next(count) })
}
var counts = new Observable(function subscribe (observer) {
var i = observers.length
observers.push(observer)
observer.next(count)
return function unsubscribe () { observers.splice(i, 1) }
})
counts.subscribe(function onNext (count) {
console.log('Count: ', count)
})
var jsx = Vulture.jsx
var app =
jsx('p', [
counts.map(function computeClickedText (count) {
return 'Clicked: ' + count + ' times'
}),
' ',
jsx('button', { onClick: increment }, ['+']),
jsx('button', { onClick: decrement }, ['-']),
])
Vulture.render(app, document.getElementById('app'))
</script>
</body>
</html>