0.0.4 • Published 2 years ago

pinia-plugin-autosetter v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

⚙️ Installing

  1. Install with your favorite package manager:

    • pnpm : pnpm i pinia-plugin-autosetter
    • npm : npm i pinia-plugin-autosetter
    • yarn : yarn add pinia-plugin-autosetter
  2. Add the plugin to pinia:

import { createPinia } from 'pinia'
import autoSetter from 'pinia-plugin-autosetter'

const pinia = createPinia()
pinia.use(autoSetter)

🚀 Usage

You just need to add the autosetter option to the store you want to be automatically set the setter corresponding to State as follows:

import { defineStore } from 'pinia'

//* using option store syntax
export const useCounterStore = defineStore('counter', {
  state: () => {
    return {
      count: 0,
    }
  },
  autosetter: true,
})

//* or using setup store syntax
export const useStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    return { count }
  },
  {
    autosetter: true,
  },
)
const counterStore = useCounterStore()
counterStore.setCount(10) // { count: 10 }

📝 License

Copyright © 2022 Chengbo Xie.
This project is under MIT license.

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago