Skip to content

Getter with parameters … #42

Answered by andrewcourtice
s5b asked this question in Q&A
Nov 15, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi Stuart

Thank you for your kind words - I really appreciate it.

Although historically Vuex has enabled the use of getters with parameters, I have made the conscious decision to not include that functionality as part of Harlem as the same result can now be achieved using just a function and leaning on Vue's reactivity system to re-evaluate the function once a dependency changes.

Given your use-case above, here's how you might achieve what you are describing:

/*
Assuming you have a state structure something like:
{
    departments: [
        {
            id,
            email
        }
    ]
}
*/

import {
    state
} from './store';

export function getDepartmentEmail(departmentId: string)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@s5b
Comment options

@andrewcourtice
Comment options

Answer selected by andrewcourtice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants