Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VueX getter caching in combination with VueX-ORM #116

Open
SimonDatapas opened this issue Jan 26, 2022 · 0 comments
Open

VueX getter caching in combination with VueX-ORM #116

SimonDatapas opened this issue Jan 26, 2022 · 0 comments

Comments

@SimonDatapas
Copy link

Additional context

I'm not totally sure wether I'm posting this in the right repo, but I thought it might be usefull for everyone here to know.

Describe the bug / Expected behaviour

It seems that when querying VueX-ORM models inside a VueX store getter, the getter can't cache the result properly.
I have a store getter that contains a query that can take up to a full second to return the requested data (yes, lots of data).
When I call this getter twice from inside a component, the render time needed will be 2 seconds instead of 1.
If I would refactor this getter to be a state property and be updated everytime the corresponding repo's would be updated, The render time will be reduced to an instant and the time to mutate the repo's will take 1 second longer.
I would expect in my first scenario that the render time wouldn't increase no matter how many times the getter would be called from within that component. (For as far as I understand, this behaviour would be the same as store getter caching where getters only refer to store state.)

Steps to reproduce the bug

// Template inside component
<template>
   <section v-for="post in posts">{{post.name}}</section>
   <section v-for="post in posts">{{post.name}}</section>
</template>

// Computed property inside component
posts() {
    return this.$store.getters.posts;
}

// Store
getters: {
    posts() {
        return store.$repo(Post).all();
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant