title: How to run a function in Vue.js when state changes
body: <p>I'm looking to run a function when the state changes in my Vue app.
  In my component I'm able to get the boolean state of isOpen. I'm looking to run a function that adds focus to my form input when the modal opens and isOpen is set to true. I've tried using a watcher but with no luck. I'm opening my modal by calling :class="{ 'is-open': search.isOpen }" in the html and showing it via css. Any help would be most appreciated.</p>
  
  <pre><code>data() {
      return {
        isFocussed: this.$store.state.search,
        //checks the state of isOpen?
      }
    },
  
    computed: {
      search() { return this.$store.state.search },
    },
  
    watch: {
      isFocussed() {
       this.formfocus()
      },
    },
  
    methods: {
      formfocus() {
        document.getElementById('search').focus()
      },
  </code></pre>