21 lines
524 B
JavaScript

/* eslint-disable import/prefer-default-export */
import { useStore } from 'stores/hooks';
import { useDebouncedCallback } from 'use-debounce';
const DEBOUNCE_DELAY = 350;
export function useValue(valueName) {
const { $calculation } = useStore();
const storeValue = $calculation.$values.observeValue(valueName);
const setStoreValue = useDebouncedCallback((value) => {
$calculation.$values.setValue(valueName, value);
}, DEBOUNCE_DELAY);
return {
value: storeValue,
setValue: setStoreValue,
};
}