Last active
February 29, 2020 15:49
-
-
Save darkylmnx/d2aa84bc7830eedc783132d40bc97373 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() { | |
return { ...useCounterUp(10), ...useCounterDown(5) }; | |
// both "counter" variables in use... will collide | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment