Forked from darkylmnx/vue_composition_collisions_demo.js
Last active
February 29, 2020 15:55
This file contains hidden or 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