Skip to content

Instantly share code, notes, and snippets.

@darkylmnx
Last active February 29, 2020 15:49
Show Gist options
  • Save darkylmnx/d2aa84bc7830eedc783132d40bc97373 to your computer and use it in GitHub Desktop.
Save darkylmnx/d2aa84bc7830eedc783132d40bc97373 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() {
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