@stateref/connect-vue
v3.2.0
Published
Vue connector for state-ref
Readme
state-ref Vue Connector (connectVue)
Usage with Vue
In Vue, the store is connected and returns Vue's built-in reactive Reactive synchronized with the stateRef state value.
You can customize it by referring to the connectVue implementation code.
profileStore.ts
import { connectVue } from "@stateref/connect-vue";
// ... same as React example
export const useProfileStore = connectVue(watch);UserComponent.vue
<script setup lang="ts">
import { useProfileStore } from 'profileStore';
const age = useProfileStore<number>(store => store.john.age);
const incrementFromProfile = () => {
// This looks the same as stateRef, but it's a Reactive value in Vue.
age.value += 1;
};
</script>
<template>
<button @click="incrementFromProfile">
john's age is: {{ age.value }}
</button>
</template>