Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 1x 1x 57x 57x 1x 1x 53x 53x 5x 5x 3x 4x | // @ts-check import { get } from "lodash"; import { createStore, getStore } from "./index"; import { sync } from "vuex-router-sync"; import d from "debug"; import { mixinMaker } from "../utils"; const debug = d("base:store"); export const BaseStoreMixin = mixinMaker({ beforeCreate() { const baseStore = createStore(); if (!baseStore?.state?.route && this.$router) { debug("registering route in store"); sync(baseStore, this.$router); } }, methods: { /** * @return {V.Store<BaseVue.StoreState>|undefined} */ getBaseStore() { return getStore(); }, /** * @param {string|string[]} path * @return {any} */ getBaseState(path) { const state = getStore()?.state; return get(state, path); }, /** * @param {string|string[]} path * @return {any} */ getBaseGetter(path) { const getters = getStore()?.getters; return get(getters, path); }, /** * @param {string} path * @param {any} value * @return {any} */ commitBase(path, value) { return getStore()?.commit?.(path, value); }, /** * @param {string} path * @return {any} */ dispatchBase(path) { return getStore()?.dispatch?.(path); } } }); |