1.0.8 • Published 6 months ago

@jswork/pinia-plugin-watch v1.0.8

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

pinia-plugin-watch

The easiest way to watch for your Pinia State.

version license size download

installation

npm install @jswork/pinia-plugin-watch

usage

import PiniaPluginWatch from '@jswork/pinia-plugin-watch';

// ======== main.js  ======
export function createApp() {
  const app = createSSRApp(App);
  const pinia = createPinia();

  pinia.use(PiniaStateTree);
  pinia.use(piniaPluginWatch);
  //...
}

// ======== stores/auth.js ======
import { defineStore } from "pinia";

export default defineStore("auth", {
  state: () => ({ profile: null, other: null }),
  watch: {
    profile: (newValue, oldValue) => {
      if (newValue) console.log("profile changed", newValue);
      else console.log("profile removed", oldValue);
    },
  },
});

license

Code released under the MIT license.

1.0.8

6 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago