Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hootlex/9ec0317ec4c455dfe636a93560f3eee9 to your computer and use it in GitHub Desktop.
Save hootlex/9ec0317ec4c455dfe636a93560f3eee9 to your computer and use it in GitHub Desktop.
import { ref } from 'vue';
const useCounterUp = (initialVaue = 0) => {
const counter = ref(initialVaue);
const increment = () => counter.value += 1;
return { counter, increment };
};
const useCounterDown = (initialVaue = 0) => {
const counter = ref(initialVaue);
const decrement = () => counter.value += 1;
return { counter, decrement };
};
export default {
setup() {
const {counter: counterUp, increment: incrementCounterUp} = useCounterUp(10)
const {counter: counterDown, decrement: decrementCounterDown} = useCounterUp(10)
return { counterUp, counterDown, incrementCounterUp, decrementCounterDown };
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment