Skip to content

Is there any way to define and use state in the model, same way as it was in Vuex? #1895

Closed Answered by Derranion
Derranion asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the replies I ended up with just creating a static variable with a ref inside of the class.

Here is an example:

import { Model } from 'pinia-orm'
import { ref } from 'vue'

export default class AnyName extends Model {
    ...
    static state = ref({
        loading: false,
        total: 0,
    })
    ...
}

Replies: 2 comments 2 replies

Comment options

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

@CodeDredd
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Derranion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants