0.0.5 • Published 10 months ago

pinia-store-helper v0.0.5

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

Pinia Store Helper

A vue plugin to help manage complex pinia stores.

Installation and usage

Register plugin

import { piniaStoreHelperPlugin } from "pinia-store-helper";
const app = createApp(App)
app.use(createPinia())
app.use(piniaStoreHelperPlugin)

Component

Then add the component.

<PiniaStoreHelper>
    <template #main>
        <!-- Your components goes here -->
    </template>
    <template #error>
        An error occured.
    </template>
</PiniaStoreHelper>

Usage

// With the following store:
const useMyStore = defineStore("myStore", () => {
    const counter = ref<null | number>(null);
    return { counter };
})
const store = useMyStore();
const { counter } = storeToRefs(store);
// counter is Ref<string | null>
// If you know you are at a certain place where counter has been properly initialized, then use nonNullRef
const counter = nonNullRef(store, 'counter')
// counter is now Ref<string>, and will show an error if not.
0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago