Skip to content

Instantly share code, notes, and snippets.

@brandonaaskov
Created January 18, 2020 22:45
Show Gist options
  • Save brandonaaskov/9fd708f2cb08bddcbfc3a6ff4ea29ed3 to your computer and use it in GitHub Desktop.
Save brandonaaskov/9fd708f2cb08bddcbfc3a6ff4ea29ed3 to your computer and use it in GitHub Desktop.
// 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