Vue 2 - vuex mapGetters and pass params

Viewed 24185

Is it possible to pass params with mapGetters?

I have this in main Vue instance:

computed: {
    filterAuthors() {
        return this.$store.getters.filterAuthors(this.search.toLowerCase());
    }
}

this.search is bind to the input field via v-model="search=, and in my Vuex instance I have this getters:

getters: {
    filterAuthors: (state) => (search) => {
        return state.authors.filter((author) => {
            return author.name.toLowerCase().indexOf(search) >= 0;
        })
    }
},

This one is working fine, but I am trying to find a way (if it is possible) to use mapGetters and to pass the argument. Can this be done?

2 Answers
Related