title: VueJs child component props not updating instantly
body: <p>I have a parent/child component setup where the parent is loading data from the server and passing it down to children via props. In the child I would like to instantiate a jQuery calendar with some of the data it receives from the parent.</p>
  
  <p>In order to wait for the data before setting up the calendar, I broadcast an event in the parent that I have an event listener setup for in the child.</p>
  
  <p>The listener is being fired in the child but if I <code>this.$log('theProp')</code>, it's undefined. However, if I inspect the components with the VueJs devtools, the parent/child relationship is there and the child has received the prop in the meantime.</p>
  
  <p>The prop is defined on the child as a dynamic prop <code>:the-prop="theProp"</code>. Since the child does receive the prop in the end, I'm assuming my setup is correct but there seems to be some sort of delay. The parent sets the props in the return function of the ajax call and again: it's working, just with a slight delay it seems.</p>
  
  <p>I also tried registering a <code>watch</code> listener on the prop in the child so I could setup the calendar then and be sure that the prop is there. However, the watch listener fires, but <code>this.$log('theProp')</code> is still undefined.</p>
  
  <p>If I pass the data along with the the broadcast call, like <code>this.$broadcast('dataLoaded', theData)</code> the child receives it just fine. But it seems wrong to do it that way as I'm basically building my own prop handler.</p>
  
  <p>I'm not posting any code because the components are rather large and the VueJs devtools are telling me the parent/child situation is working.</p>
  
  <p>Am I missing some information? Is there a slight delay between setting a value in the parent and the child receiving it? What would be the proper way to wait for parent data in the child? </p>
  
  <p>Normally, when you're just rendering the data out into the template, the timing doesn't matter so much since the data is bound to the template. But in this case, I really need the data to be there to setup the calendar or it will be wrong.</p>
  
  <p>Thanks.</p>
  
  <p><strong>edit 1:</strong> here's a jsfiddle: <a href="https://jsfiddle.net/dr3djo0u/1/" rel="noreferrer">https://jsfiddle.net/dr3djo0u/1/</a>
  It seems to confirm that the data is not available immediately after the broadcast. However, the watcher does work, though I could almost swear that sometimes <code>this.$log('someData')</code> returned <code>undefined</code> when I setup that testcase.</p>
  
  <p>But I guess my problem might be somewhere else, I'll have a look tonight, don't have the project with me right now.</p>
  
  <p><strong>edit 2:</strong> did some more tests. My problem was that a) event listeners do not seem to receive the data instantly and b) I was also trying to init the calendar in the <code>route.data</code> callback if <code>someData</code> was already around (e.g. when coming from parent), but that route callback is called before the component is ready, so it wasn't working there either.</p>
  
  <p>My solution is now this:</p>
  
  <pre><code>// works when the child route is loaded directly and parent finishes loading someData
  watch: {
      someData() {
          this.initCalendar();
      }
  },
  
  // works when navigating from parent (data already loaded)
  ready() {
      if (this.someData &amp;&amp; this.someData.length) {
          this.initCalendar()
      }
  }
  </code></pre>