Reputation: 1070
What i want?
Countdown when click play button
Code
I use vuejs and vuerx to do this. here my code
<script>
/* eslint-disable */
import { Observable, Subscription } from 'rxjs'
export default {
data() {
return {
energy: 12
}
},
domStreams: ["play$"],
subscriptions() {
const energy$ = Observable.interval(250)
.fromEvent(play$, 'click')
.startWith(this.energy)
.scan(time => time - 1)
.takeWhile(time => time > 0)
return {
energy$
}
}
}
</script>
my HTML
<template>
<div>
<button @click="play$">Play</button>
<input type="text" v-model="energy">
<br>
<h1>{{ energy$ }}</h1>
</div>
</template>
Error message :
Upvotes: 0
Views: 560