How to dynamically set the immediate property in watch?

Viewed 371

These components may be used in different places, some need the immediate attribute in the watch, some do not need

Boolean values related to variables are invalid

watch:{
        color:{
          handler () {
            let rgba = this.color.rgba;
            let currentColor = rgba.a === 1 ? this.color.hex : `rgba(${rgba.r},${rgba.g},${rgba.b},${rgba.a})`;
            this.submit('color',this.now,currentColor)
          },
          immediate: !(this.now==="standard")

        }
      }
1 Answers

I would try set the watch property on your vue instance once you have the value you want then wrote something like this:

//get info for my immediate value then instantiate a watcher like this:
this.$watch('$data.color', this.handler, { deep: true })
or 
this....{deep: false}
Related