typescriptVueintermediate
Vue 3 Composition API Composable
Ref, computed, and reactive state management in Vue 3
By ApeType Staff·17 lines·367 characters·1,420 total attempts
import { ref, computed } from "vue";
export function useCounter(initialValue: number = 0) {
const count = ref<number>(initialValue);
const doubleCount = computed(() => count.value * 2);
function increment() {
count.value++;
}
function decrement() {
if (count.value > 0) {
count.value--;
}
}
return { count, doubleCount, increment, decrement };
}
TRANSCRIBE
Ready when you are.
Test your muscle memory and transcription speed against this exact snippet.
Start Typing
Tip: Press Esc anytime to restart
Best runs on this snippet
| # | Typist | Acc | WPM |
|---|---|---|---|
| 1 | Abel Gideon | 95.6% | 70 |
| 2 | Abel Gideon | 95.6% | 70 |
| 3 | Abel Gideon | 98.29% | 69 |
| 4 | Abel Gideon | 98.29% | 69 |
| 5 | Henok Yoseph | 93.71% | 54 |