Skip to content

Commit

Permalink
clean up and add immediate to selected watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Sep 25, 2019
1 parent c8f6521 commit 084e04b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/RecursiveForm/RecursiveForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,11 @@ export default {
*/
handler(newOption) {
this.mutableOption = newOption;
this.setSelected();
},
immediate: true,
if (!this.hasDependency) {
this.setSelected();
}
},
/**
* Set deep to true to detect the Array choices changing. If we don't use this watcher the application can't
Expand All @@ -331,19 +332,26 @@ export default {
* @see https://stackoverflow.com/questions/42133894/vue-js-how-to-properly-watch-for-nested-data
*/
deep: true,
/**
* To run the handler on creation.
*/
immediate: true,
},
/**
* Watch the value of selected to emit a change event.
*/
selected: {
/**
* @param {*} value - New value for current option.
*/
handler(value) {
this.$configBus.$emit(EVENTS.UPDATE, { name: this.mutableOption.name, value });
},
deep: typeof selected !== 'string',
immediate: true,
},
},
created() {
Expand All @@ -353,8 +361,6 @@ export default {
if (this.hasDependency) {
this.$configBus.$on(EVENTS.AFTER_UPDATE, this.listeners.updateDependency);
} else {
}
},
Expand Down

0 comments on commit 084e04b

Please sign in to comment.