Created
January 18, 2020 22:45
-
-
Save brandonaaskov/9fd708f2cb08bddcbfc3a6ff4ea29ed3 to your computer and use it in GitHub Desktop.
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
// YUCKY VERSION | |
// using mapGetters with an array of strings | |
export default { | |
computed: { | |
...mapGetters(['movies/byStudio']), | |
disneyMovies () { | |
// this is the yucky part | |
return this['movies/byStudio']('Disney') | |
} | |
} | |
} | |
// BETTER VERSION | |
// using mapGetters as an object with keys | |
export default { | |
computed: { | |
...mapGetters({ byStudio: 'movies/byStudio' }), | |
disneyMovies () { | |
// much more normal looking | |
return this.byStudio('Disney') | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment