Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Vue from 'vue';
- import { ActionTree, MutationTree, GetterTree } from './type_helper';
- import { cloneDeep } from 'lodash';
- type Entity = {
- value: string
- }
- type EntityState = {
- records: Entity[];
- errors: { [key: string]: boolean; };
- };
- type EntityMutations = {
- set: object[];
- };
- type EntityActions = {
- getList: (payload: null) => Promise<void>;
- };
- type EntityGetters = {
- records: Entity[];
- };
- export const state = (): EntityState => ({
- records: [],
- errors: {},
- });
- export const mutations: MutationTree<EntityState, EntityMutations> = {
- set: (state, payload) => {
- Vue.set(state, 'records', payload);
- Vue.set(state, 'errors', {});
- },
- };
- export const actions: ActionTree<EntityState, EntityMutations, EntityGetters, EntityActions> = {
- getList: async ({ commit }) => {
- commit('set', []);
- }
- };
- export const getters: GetterTree<EntityState, EntityGetters> = {
- records: (state) => cloneDeep(state.records),
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement