19 lines
445 B
TypeScript
19 lines
445 B
TypeScript
import { Ref, nextTick, ref, watch } from 'vue';
|
|
|
|
export async function toggleTickAsync(tick: Ref<boolean>, numTimes = 1) {
|
|
for (let i = 0; i < numTimes; i++) {
|
|
tick.value = true;
|
|
await nextTick();
|
|
tick.value = false;
|
|
await nextTick();
|
|
}
|
|
}
|
|
|
|
export function usePulseCount(pulse: Ref<boolean>) {
|
|
const pulseCount = ref(0);
|
|
watch(pulse, (newPulse) => {
|
|
if (newPulse) pulseCount.value++;
|
|
});
|
|
return { pulseCount };
|
|
}
|