1
0

feat: move from life cycle to data or watcher

- remove from created / mounted
- initialize component services in data
- use immediate watcher where appropriate
- deep watch for route changes
This commit is contained in:
Dominik Pschenitschni
2021-09-08 11:59:38 +02:00
committed by kolaente
parent ebeca48be4
commit f51371bbe0
59 changed files with 246 additions and 376 deletions

View File

@ -48,16 +48,16 @@ export default {
},
},
watch: {
value(newVal) {
this.color = newVal
value: {
handler(value) {
this.color = value
},
immediate: true,
},
color() {
this.update()
},
},
mounted() {
this.color = this.value
},
computed: {
empty() {
return this.color === '#000000' || this.color === ''

View File

@ -151,15 +151,15 @@ export default {
},
},
mounted() {
this.setDateValue(this.value)
document.addEventListener('click', this.hideDatePopup)
},
beforeDestroy() {
document.removeEventListener('click', this.hideDatePopup)
},
watch: {
value(newVal) {
this.setDateValue(newVal)
value: {
handler: 'setDateValue',
immediate: true,
},
flatPickrDate(newVal) {
this.date = createDateFromString(newVal)

View File

@ -26,7 +26,7 @@ export default {
data() {
return {
checked: false,
checkBoxId: '',
checkBoxId: 'fancycheckbox' + Math.random(),
}
},
props: {
@ -40,16 +40,14 @@ export default {
},
},
watch: {
value(newVal) {
this.checked = newVal
value: {
handler(value) {
this.checked = value
},
immediate: true,
},
},
mounted() {
this.checked = this.value
},
created() {
this.checkBoxId = 'fancycheckbox' + Math.random()
},
methods: {
updateData(checked) {
this.checked = checked

View File

@ -190,14 +190,16 @@ export default {
},
mounted() {
document.addEventListener('click', this.hideSearchResultsHandler)
this.setSelectedObject(this.value)
},
beforeDestroy() {
document.removeEventListener('click', this.hideSearchResultsHandler)
},
watch: {
value(newVal) {
this.setSelectedObject(newVal)
value: {
handler(value) {
this.setSelectedObject(value)
},
immediate: true,
},
},
computed: {