@@ -40,7 +40,10 @@ export default {
40
40
},
41
41
computed: {
42
42
// needs access to current component aka activeComponent
43
- ... mapState ([' componentMap' , ' activeComponent' , ' activeComponentObj' ])
43
+ ... mapState ([' componentMap' , ' activeComponent' , ' activeComponentObj' ]),
44
+ activeObj (){
45
+ return this .activeComponentObj
46
+ }
44
47
},
45
48
methods: {
46
49
getWindowHeight (e ) {
@@ -137,12 +140,12 @@ export default {
137
140
138
141
// add import mapstate and mapactions if they exist
139
142
let imports = ' '
140
- if (this .activeComponentObj .actions .length || this .activeComponentObj .state .length ){
143
+ if (this .activeObj .actions .length || this .activeObj .state .length ){
141
144
imports += ' import { '
142
- if (this .activeComponentObj .actions .length && this .activeComponentObj .state .length ) {
145
+ if (this .activeObj .actions .length && this .activeObj .state .length ) {
143
146
imports += ' mapState, mapActions'
144
147
}
145
- else if (this .activeComponentObj .state .length ) imports += ' mapState'
148
+ else if (this .activeObj .state .length ) imports += ' mapState'
146
149
else imports += ' mapActions'
147
150
imports += ' } from "vuex"\n '
148
151
}
@@ -160,9 +163,9 @@ export default {
160
163
161
164
// if true add data section and populate with props
162
165
let data = ' '
163
- if (this .activeComponentObj .props .length ){
166
+ if (this .activeObj .props .length ){
164
167
data += ' data () {\n return {'
165
- this .activeComponentObj .props .forEach (prop => {
168
+ this .activeObj .props .forEach (prop => {
166
169
data += ` \n ${ prop} : "PLACEHOLDER FOR VALUE",`
167
170
})
168
171
data += ' \n '
@@ -172,10 +175,10 @@ export default {
172
175
173
176
// if true add computed section and populate with state
174
177
let computed = ' '
175
- if (this .activeComponentObj .state .length ){
178
+ if (this .activeObj .state .length ){
176
179
computed += ' computed: {'
177
180
computed += ' \n ...mapState(['
178
- this .activeComponentObj .state .forEach ((state ) => {
181
+ this .activeObj .state .forEach ((state ) => {
179
182
computed += ` \n "${ state} ",`
180
183
})
181
184
computed += ' \n ]),\n '
@@ -184,10 +187,10 @@ export default {
184
187
185
188
// if true add methods section and populate with actions
186
189
let methods = ' '
187
- if (this .activeComponentObj .actions .length ){
190
+ if (this .activeObj .actions .length ){
188
191
methods += ' methods: {'
189
192
methods += ' \n ...mapActions(['
190
- this .activeComponentObj .actions .forEach ((action ) => {
193
+ this .activeObj .actions .forEach ((action ) => {
191
194
methods += ` \n "${ action} ",`
192
195
})
193
196
methods += ' \n ]),\n '
@@ -213,6 +216,14 @@ export default {
213
216
return output
214
217
}
215
218
},
219
+ watch: {
220
+ // watches activeComponentObj for changes to make it reactive upon mutation
221
+ activeComponentObj: {
222
+ handler (){
223
+ this .code = this .createCodeSnippet (this .activeComponentObj .componentName , this .activeComponentObj .children )
224
+ }
225
+ }
226
+ },
216
227
mounted () {
217
228
// https://vuejs.org/v2/api/#Vue-nextTick
218
229
// kinda like a promise, used for the window resize
0 commit comments