1.1.3 • Published 10 months ago

pinia-class-store v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Class Style Store for pinia

inspired by vuex-class-modules

Install

pnpm add pinia-class-store

Usage

//define Store
import {useStore} from 'pinia-class-store'

class TestStore {
    //state
    hello = "INIT"

    //getters
    get helloMe() {
        return this.hello + "me"
    }

    //actions
    changeHello() {
        this.hello = "hello"
    }

    async asyncHello() {
        await new Promise(resolve => setTimeout(resolve, 1000))
        this.changeHello()
    }
}

setActivePinia(createPinia())
//use store
const store = useStore(TestStore)
//access store like normal class
console.log(store.hello)
await store.asyncHello()
console.log(store.helloMe)

//If you want name it
export const useAnotherTestStore = useStore.bind(undefined, TestStore, "another_name")

License - MIT

I would thank you if you give this a star.

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago