@empathyco/x-components
Version:
Empathy X Components
28 lines (25 loc) • 851 B
JavaScript
import { computed } from 'vue';
import { useStore } from 'vuex';
import '../plugins/x-bus.js';
import '@empathyco/x-utils';
import '../plugins/x-plugin.js';
import { getGetterPath } from '../plugins/x-plugin.utils.js';
/**
* Function which returns the requested getter's properties as a dictionary.
*
* @param module - The {@link XModuleName} of the getter.
* @returns The requested getters from the module.
* @public
*/
const useGetter = function useGetter(module) {
const store = useStore();
return new Proxy({}, {
get(_obj, getterName) {
const path = getGetterPath(module, getterName);
// eslint-disable-next-line ts/no-unsafe-member-access,ts/no-unsafe-return
return computed(() => store.getters[path]);
},
});
};
export { useGetter };
//# sourceMappingURL=use-getter.js.map