Forked from darkylmnx/vue_composition_collisions_demo.js
Last active
February 29, 2020 15:55
-
-
Save hootlex/9ec0317ec4c455dfe636a93560f3eee9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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