@@ -16,26 +16,23 @@ export function createModule( options ?:VuexModuleOptions ) {
16
16
* options variable as it is an internal variable.
17
17
*/
18
18
( VuexModule as VuexModuleConstructor ) . prototype . __options__ = options ;
19
- ( VuexModule as VuexModuleConstructor ) . prototype . __namespacedPath__ = "" ;
20
- ( VuexModule as VuexModuleConstructor ) . prototype . __vuex_module_cache__ = undefined ;
21
- ( VuexModule as VuexModuleConstructor ) . prototype . __vuex_proxy_cache__ = undefined ;
22
- ( VuexModule as VuexModuleConstructor ) . prototype . __vuex_local_proxy_cache__ = undefined ;
23
- ( VuexModule as VuexModuleConstructor ) . prototype . __submodules_cache__ = { } ;
24
- ( VuexModule as VuexModuleConstructor ) . prototype . __context_store__ = { } ;
25
- ( VuexModule as VuexModuleConstructor ) . prototype . __mutations_cache__ = {
26
- __explicit_mutations__ : { } ,
27
- __setter_mutations__ : { }
28
- } ;
29
- ( VuexModule as VuexModuleConstructor ) . prototype . __explicit_mutations_names__ = [ ] ;
30
- ( VuexModule as VuexModuleConstructor ) . prototype . __actions__ = [ ] ;
31
- ( VuexModule as VuexModuleConstructor ) . prototype . __watch__ = { } ;
32
- ( VuexModule as VuexModuleConstructor ) . prototype . __explicit_getter_names__ = [ ] ;
33
- ( VuexModule as VuexModuleConstructor ) . prototype . __decorator_getter_names__ = [ ] ;
34
19
35
20
return VuexModule ;
36
21
37
22
}
38
23
24
+
25
+ function initializeModuleInternals ( cls : VuexModuleConstructor ) {
26
+ cls . prototype . __namespacedPath__ = "" ;
27
+ cls . prototype . __vuex_module_cache__ = undefined ;
28
+ cls . prototype . __vuex_proxy_cache__ = undefined ;
29
+ cls . prototype . __vuex_local_proxy_cache__ = undefined ;
30
+ cls . prototype . __submodules_cache__ = { } ;
31
+ cls . prototype . __context_store__ = { } ;
32
+ cls . prototype . __watch__ = { } ;
33
+ cls . prototype . __explicit_getter_names__ = [ ] ;
34
+ }
35
+
39
36
export function extractVuexModule ( cls :typeof VuexModule ) {
40
37
41
38
const VuexClass = cls as VuexModuleConstructor ;
@@ -46,13 +43,20 @@ export function extractVuexModule( cls :typeof VuexModule ) {
46
43
return VuexClass . prototype . __vuex_module_cache__ ;
47
44
}
48
45
46
+ initializeModuleInternals ( VuexClass ) ;
47
+
49
48
// If not extract vuex module from class.
50
49
const fromInstance = extractModulesFromInstance ( VuexClass ) ;
51
50
const fromPrototype = extractModulesFromPrototype ( VuexClass ) ;
52
51
52
+ // console.log( "Class Name", VuexClass, VuexClass.name, VuexClass.prototype.__mutations_cache__ )
53
+ // console.log( "Mutation Names", VuexClass.name, VuexClass.prototype.__actions__ )
54
+
53
55
// Cache explicit mutations and getter mutations.
54
- VuexClass . prototype . __mutations_cache__ . __explicit_mutations__ = fromPrototype . mutations . explicitMutations ;
55
- VuexClass . prototype . __mutations_cache__ . __setter_mutations__ = fromPrototype . mutations . setterMutations ;
56
+ VuexClass . prototype . __mutations_cache__ = {
57
+ __explicit_mutations__ : fromPrototype . mutations . explicitMutations ,
58
+ __setter_mutations__ : fromPrototype . mutations . setterMutations ,
59
+ }
56
60
const className = VuexClass . name . toLowerCase ( ) ;
57
61
58
62
const vuexModule :VuexObject = {
@@ -69,7 +73,7 @@ export function extractVuexModule( cls :typeof VuexModule ) {
69
73
70
74
const rtn = { [ path ] : vuexModule }
71
75
VuexClass . prototype . __vuex_module_cache__ = rtn ;
72
-
76
+
73
77
return rtn ;
74
78
75
79
}
@@ -260,7 +264,7 @@ function extractModulesFromPrototype( cls :VuexModuleConstructor ) {
260
264
261
265
}
262
266
263
- function extractDecoratorGetterNames ( names :string [ ] ) {
267
+ function extractDecoratorGetterNames ( names :string [ ] = [ ] ) {
264
268
const decorator :Map = { } ;
265
269
for ( let name of names ) {
266
270
decorator [ name ] = new Function ( "state" , `return state.${ name } ` ) ;
0 commit comments