Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created August 1, 2017 17:38
Show Gist options
  • Save AlbinoDrought/a02f1f4106731710ec79ccdc9caa7380 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/a02f1f4106731710ec79ccdc9caa7380 to your computer and use it in GitHub Desktop.
Vue.js mixin to reduce `mount` and `watch` boilerplate
function mountWatch(propName, methodName) {
const mixin = {
mounted() {
this[methodName]();
},
watch: {
[propName]() {
this[methodName]();
},
},
};
return mixin;
}
export default mountWatch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment