0.0.5 • Published 1 year ago

@renewx/vue3 v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@renewx/vue3

npm version GitHub license

Installation

Install via npm:

npm i @renewx/vue3

Or via yarn:

yarn add @renewx/vue3

Usage

Store state

Subscribe to store changes and use reactive store state

⚠️ But remember that useStore returns ShallowRef<Freeze<T>>

⚠️ If you're utilizing dynamically created store or adapter, it's important to pass true as the second parameter in useStore.

This indicates that upon exiting the scope, not only will the change listener be cleared, but store.off() will also be invoked, ensuring proper cleanup.

<script setup lang="ts">
  import { store } from "@renewx/core";
  import { useStore } from "@renewx/vue3";
  import { title } from "../stores/title";
  import { user } from "../stores/user";

  const Title = useStore(title);
  const User = useStore(user);
  const IsShow = useStore(store(false, "IS-SHOW"), { withOff: true });
</script>

<template>
  <h1 v-text="Title" />
  <button v-on:click="IsShow = !IsShow">Toggle me</button>
  <span v-if="IsShow">{{ User.nickname }}</span>
</template>

In useStore, you can pass a configuration object with the following parameters:

  • withOff: boolean – when true, the store is automatically removed upon component unmount in Vue 3.
  • stateCheck: boolean – when false, state change checks are disabled.

Docs

Read full docs here.

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago