UNPKG

vue-rest-hooks

Version:

typescript restfull-api reactive @vue/composition-api

24 lines (23 loc) 961 B
import { computed } from "@vue/composition-api"; import { normalizeNamespace, isValidMap, normalizeMap, getModuleByNamespace } from "../utils"; export var mapStateConvert = function (store) { return normalizeNamespace(function (store, namespace, states) { var res = {}; if (process.env.NODE_ENV !== "production" && !isValidMap(states)) { console.error("[vuex] mapState: mapper parameter must be either an Array or an Object"); } normalizeMap(states).forEach(function (_a) { var key = _a.key; var state = store.state; if (namespace) { var module_1 = getModuleByNamespace(store, "mapState", namespace); if (!module_1) { return; } state = module_1.context.state; } res[key] = computed(function () { return state[key]; }); }); return res; }, store); };