Non-Partisan Magicians

    pinia-plugin-autosetter
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.4 • Public • Published

    Artwork from Pinia

    pinia-plugin-autosetter

    Auto Setter

    ⚙️ 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.

    Keywords

    none

    Install

    npm i pinia-plugin-autosetter

    DownloadsWeekly Downloads

    11

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    6.63 kB

    Total Files

    6

    Last publish

    Collaborators

    • chengbo