question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is needed to support getters with parameters?

See original GitHub issue

Hi there!

What would need to be done in order to support getters with parameters, and how should they work ideally?

How do they differ from actions? Is there a way where you could return a computed from an action in order to mimic the same functionality?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
posvacommented, Mar 24, 2020

It’s fine, lol

I was more thinking about replacing that 15 in the example with the computed:

const bookmarksStore = useBookmarksStore();
const userID = ref(15);

const bookmark = computed(() => bookmarksStore.getBookmarkForUser(userID.value)

But sometimes that’s not possible because the variable comes from a loop, so you have to use the action in the template, in that case you return a function that calls the action in setup:

function getBookmarkForUser(id) {
  return bookmarStore.getBookmarkStore(id)
}

return { getBookmarkForUser }

and then use it in the template

1reaction
posvacommented, Mar 21, 2020

hello. I don’t think getters with parameters are worth anymore. They are just methods. Otherwise it would mean creating some kind of internal Map of computed properties depending on the parameters

Read more comments on GitHub >

github_iconTop Results From Across the Web

vuexjs getter with argument - Stack Overflow
This should be the accepted answer as a) it answers the question, and b) it doesn't promote bad practices. Accepted answer is just...
Read more >
How to pass parameters to the function in getters #688 - GitHub
Use a getter to 'shape' the data into what's needed by your app. 3
Read more >
Getters | Vuex
The mapGetters Helper. The mapGetters helper simply maps store getters to local computed properties: import { mapGetters } from 'vuex' export ...
Read more >
How do you pass a parameter to a getter method?
Say I want to pass a parameter to a getter method statically in my visualforce code. For example: <apex:pageBlockTable value="{!
Read more >
Vuex Getter With Parameters In TypeScript
Vuex supports “method-style” getters which are getters that return a function with one or more parameters. ... In this example, the getter returns ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found