0.0.1 • Published 3 years ago
v-zustand v0.0.1
v-zustand
Zustand state management for Vue 2 and 3.
Install
yarn add v-zustand
Example
// store/bear.ts
import create from 'zustand/vanilla'
interface BearState {
bears: number
increase: () => void
}
export const bearStore = create<BearState>(set => ({
bears: 0,
increase: () => set(state => ({ bears: state.bears + 1 }))
}))
<!-- Component.vue -->
<template>
<h1>{{ state.bears }} around here ...</h1>
<button @click="state.increase">one up</button>
</template>
<script setup lang="ts">
import { useStore } from 'v-zustand'
import { bearStore } from './store/bear'
const state = useStore(bearStore)
</script>
License
MIT License © 2021 Robert Soriano
0.0.1
3 years ago