import { useStore } from "effector-vue/composition";
A hook function, which subscribes to watcher, that observes changes in the current readonly store, so when recording results, the component will update automatically. You can mutate the store value only via createEvent. Designed for vue 3
useStore($store)
Arguments
$store
(Store<State>
)
Returns
(readonly(State)
)
Example
import { createStore, createApi } from "effector";
import { useStore } from "effector-vue/composition";
const $counter = createStore(0);
const { incremented, decremented } = createApi($counter, {
incremented: (count) => count + 1,
decremented: (count) => count - 1,
});
export default {
setup() {
const counter = useStore($counter);
return {
counter,
incremented,
decremented,
};
},
};