Skip to content

Commit 17aa950

Browse files
committed
feat(playground): add counter command as button example
1 parent 2990716 commit 17aa950

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { computed, ref } from 'vue'
2+
3+
/**
4+
* @name counter
5+
* @description A simple counter command that counts button presses
6+
*/
7+
export default function counter() {
8+
const count = ref(0)
9+
const message = computed(() => `Count: ${count.value}`)
10+
11+
return reply.button(
12+
'+1',
13+
() => void (count.value += 1),
14+
// hide the button when count reaches 5
15+
{ hide: computed(() => count.value >= 5) },
16+
).send(message)
17+
}

0 commit comments

Comments
 (0)