Last active
June 23, 2021 15:53
-
-
Save fimion/69bef93fd95522951a8e212e64699a3b 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 constantMixin from './ConstantMixin.js"; | |
const MAX = 5; | |
const MIN = 0; | |
export default { | |
name:"MyComponent", | |
mixins:[ | |
constantMixin({ MAX, MIN }), | |
], | |
} |
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
export default function constantMixin(constants={}){ | |
const computed = {}; | |
Object.keys(constants).forEach((key)=>{ | |
computed[key] = ()=>constants[key]; | |
}); | |
return { computed }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment