minetoblend / pinia-make-destructurable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pinia-make-destructurable

A modified version of Pinia's storeToRefs function that will also include the actions.

Usage

import { makeStoreDestructurable } from 'pinia-make-destructurable';

const useCounterStore = defineStore('counter', () => {
  const count = ref(0);

  const increment = () => count++;

  return { count, increment };
});

const { count, increment } = makeStoreDestructurable(useCounterStore());

console.log(count.value) // 0

increment();

console.log(count.value) // 1

About


Languages

Language:TypeScript 67.2%Language:JavaScript 32.8%