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

Can't get static getters on the model (not instance) to be reactive #796

Open
fractalf opened this issue Jan 12, 2023 · 0 comments
Open

Comments

@fractalf
Copy link

I'm trying to create a reactive static model getter that returns some items that are affected by a filter.
The filter is just a normal Vuex module containing some filter properties

I want to get a list of items by calling Item.allItems and this works, except it's not reactive when I change the filter

Is there something I'm missing here? Is this not possible?

Note: I need a static getter on the Model, not a getter on an instance

// Vuex filter module 
export default {
    namespaced: true,
    state: {
        foobar: false
    },
}
// Vuex ORM model
export class Item extends Model {
    static get allItems() {
        const filter = this.store().state.filter

        const query = this.query()
        if (filter.foobar) {
            query.where('foobar', true)
        }

        return query.get()
    }
}
@fractalf fractalf changed the title Can't get static getters to be reactive Can't get static getters on the model (not instance) to be reactive Jan 12, 2023
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