@empathyco/x-components
Version:
Empathy X Components
23 lines (20 loc) • 641 B
JavaScript
import { computed } from 'vue';
import { useStore } from 'vuex';
/**
* Function which returns the requested state's properties as a dictionary.
*
* @param module - The {@link XModuleName} of the getter.
* @param paths - List of state paths.
* @returns The requested state properties of the module.
*
* @public
*/
function useState(module, paths) {
const store = useStore();
return paths.reduce((stateDictionary, path) => {
stateDictionary[path] = computed(() => store?.state.x[module]?.[path]);
return stateDictionary;
}, {});
}
export { useState };
//# sourceMappingURL=use-state.js.map