Skip to content

Access parametrized getter in setup store #2183

Discussion options

You must be logged in to vote

It is not a different feature, if you want to receive a parameter, you should return a function. As far as i know is the same for Options and Composition API:

const getEventById= computed(() => (id: string) => {
    return fetchedEvents.value.find((event) => (event.id= id)) ?? null;
  });

or

const getEventById= computed(() => {
    return (id: string) => fetchedEvents.value.find((event) => (event.id= id)) ?? null;
  });

But of course this is not recommended because it loses the cache feature

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Walnussbaer
Comment options

@ramsesmoreno
Comment options

Answer selected by Walnussbaer
@Walnussbaer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants