Is it possible to pass extra arguments to Vuex getters?
For example, I want to make a getter that can grab an object from an array based on it's id:
const state = [
{id: 1, name: "John"},
{id: 2, name: "Doe"},
{id: 3, name: "Jane"}
];
const getters = {
// The "theoretical" getter I want, which accepts an id as a second argument
byId: (state, id) => state.find( (item) => item.id === id )
};
But I can't find anywhere in the Vuex documentation that states anything about passing extra arguments to a getter when calling it from a Vue component (it mention that you can pass another getter in as an argument...but that's not what I want).
Is it even possible to do what I am looking for? And if not, how should I go about retrieving items from my state based on dynamic attributes?
Vuex getters
Is it possible to pass extra arguments to Vuex getters?
For example, I want to make a getter that can grab an object from an array based on it's id:
But I can't find anywhere in the Vuex documentation that states anything about passing extra arguments to a getter when calling it from a Vue component (it mention that you can pass another getter in as an argument...but that's not what I want).
Is it even possible to do what I am looking for? And if not, how should I go about retrieving items from my state based on dynamic attributes?