R
R
ravshan selimov2021-12-25 13:30:53
JavaScript
ravshan selimov, 2021-12-25 13:30:53

How to create one watcher to track multiple data?

Hello.
There is such a code

watch: {
    processes: {
      handler() {
        this.init();
        this.$refs.editor.reInit();
      },
      deep: true,
    },
    conditionsIds: {
      handler() {
        this.init();
        this.$refs.editor.reInit();
      },
      deep: true,
    },
    activeDialog: {
      handler() {
        this.init();
        this.$refs.editor.reInit();
      },
      deep: true,
    },
    variables: {
      handler() {
        this.init();
        this.$refs.editor.reInit();
      },
      deep: true,
    },
  },


I don't like this kind of duplicate code.
How can I simplify it, create one watcher for all this data

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-12-25
@ravshan01

Make it a computed property - an object that will contain whatever you want to keep track of. Set a watch on this property.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question