Skip to content

Commit e570fd2

Browse files
committed
fix: readme demo code
1 parent b94073d commit e570fd2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Vue timer hook is a custom [vue 3 hook](https://vue.org/docs/hooks-intro.html),
3636

3737

3838
<script lang="ts">
39-
import { defineComponent, watch } from "vue";
39+
import { defineComponent, watchEffect } from "vue";
4040
import { useTimer } from 'vue-timer-hook';
4141
4242
export default defineComponent({
@@ -46,13 +46,15 @@ export default defineComponent({
4646
// Restarts to 5 minutes timer
4747
const time = new Date();
4848
time.setSeconds(time.getSeconds() + 300);
49-
this.restart(time);
49+
this.timer.restart(time);
5050
}
5151
},
5252
mounted() {
53-
watch(timer.isExpired, (isExpired, isExpiredCount) => {
54-
console.warn('IsExpired called :', timer.isExpired.value)
55-
});
53+
watchEffect(() => {
54+
if(this.timer.isExpired.value) {
55+
console.warn('IsExpired')
56+
}
57+
})
5658
},
5759
setup() {
5860
const time = new Date();

0 commit comments

Comments
 (0)