import { computed } from "vue";
import { useStore } from "vuex";

export function useMapper(mapper: any, fn: any) {
  const store = useStore();
  const storeStateFns = fn(mapper);
  const storeState: any = {};
  Object.keys(storeStateFns).forEach((fnKey) => {
    const fn = storeStateFns[fnKey].bind({ $store: store });
    storeState[fnKey] = computed(fn);
  });
  return storeState;
}
