-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcounter-function.html
49 lines (38 loc) · 969 Bytes
/
counter-function.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
<!-- this demo requires a browser that natively supports ES2015 -->
<script src="https://unpkg.com/xstream/dist/xstream.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../dist/vue-xs.js"></script>
<div id="app">
<div>{{ count }}</div>
<!-- callback declared on streamMethods -->
<button v-on:click="muchMore(500)">Add 500</button>
<button v-on:click="minus(minusDelta1)"> Minus on Click </button>
<pre>{{ $data }}</pre>
</div>
<script>
new Vue({
el: '#app',
data () {
return {
minusDelta1: -1,
minusDelta2: -1
}
},
// declare callback Streams
streamMethods: {
muchMore: 'muchMore$',
minus:'minus$'
}, // equivalent of above: ['muchMore','minus']
subscriptions () {
var count$ = xstream.default
.merge(
this.muchMore$,
this.minus$
)
.fold((total, change) => total + change, 0)
return {
count: count$
}
}
})
</script>