-
Notifications
You must be signed in to change notification settings - Fork 1
/
_store.js
59 lines (48 loc) · 1.35 KB
/
_store.js
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
const parseModules = (types, prefix = false, suffix = '') => {
const newObj = Object.entries(types).reduce((newObj, [key, value]) => {
newObj[key] =
typeof value !== 'object'
? (prefix ? prefix + '/' : '') + value + suffix
: parseModules(value, prefix && key.toLowerCase(), suffix);
return newObj;
}, {});
return newObj;
};
const TYPE = {
ACTION: 'Action',
GETTER: 'Getter',
MUTATION: 'Mutation',
};
/* ---------------------------------------------------------------------------------------------- */
const getters = {
APP: {
NAV_DRAWER: 'navDrawer',
},
CRYPTO: {
COINS: 'coins',
},
};
export const _GETTER = getters;
export const GETTER = parseModules(getters, true);
/* ---------------------------------------------------------------------------------------------- */
const mutations = {
APP: {
NAV_DRAWER: 'navDrawer',
},
CRYPTO: {
COINS: 'coins',
},
};
export const _MUTATION = parseModules(mutations, false, TYPE.MUTATION);
export const MUTATION = parseModules(mutations, true, TYPE.MUTATION);
/* ---------------------------------------------------------------------------------------------- */
const actions = {
APP: {
UPDATE_NAV_DRAWER: 'updateNavDrawer',
},
CRYPTO: {
FETCH: 'fetch',
},
};
export const _ACTION = parseModules(actions, false, TYPE.ACTION);
export const ACTION = parseModules(actions, true, TYPE.ACTION);