Reputation: 870
I'm trying to implement a vuex getter function (with parameter) using the Typescript/ES7 Decorators provided by vuex-module-decorators.
the normal vuex implementation would look like this:
export default new Vuex.Store({
state: {
students: []
},
getters: {
findStudent: state => id => state.students.find(s => s.id == id)
}
})
The vuex-module-decorators style guide says to use Typescript getter accessor
@Module
class MyModule extends VuexModule {
students = []
get findStudent(id) {
return students.find(s => s.id == id)
}
}
Therefor, of course my linter complains A 'get' accessor cannot have parameters
What would then be the best practice to implement such getter? Or should do the logic of such function into my vue component?
Upvotes: 2
Views: 993