title: How to deal with async inputs in Components?
body: <p>I am having an issue with <code>ngOnChange</code>. I have following component:</p>
  
  <pre><code>@Component({
      selector:'user-table',
      template: `...`,
  
  })
  
  export class UserTable implements OnChanges{
      @Input() users: User[];
      years:string[];
      constructor(private _usersCollection:UsersCollection){
      }
  
      ngOnChanges(){
       if (this.users.length)
         {this.years =this._usersCollection.createYearsArray(this.users)}
      }
  }
  </code></pre>
  
  <p>However, if condition only gets checked once - when <code>this.users</code> is not yet fetched from the server, and hence its length is 0. How can I find solution to deal with this kind of async inputs?</p>
  
  <p>The array is updated, as when I set the following logs:</p>
  
  <pre><code>    console.log('ON FIRST INIT' , this.programs);
      this.years = this._usersCollection.createYearsArray();
      console.log(this.years);
      setInterval(()=&gt;{
          console.log('IN INTERVVAL' , this.programs);
      },1000);
  </code></pre>
  
  <p>The console output is:</p>
  
  <pre><code>ON FIRST INIT []
  UsersTable.component.ts:21 []
  UsersTable.component.ts:23 IN INTERVVAL [Object, Object, Object, Object]
  </code></pre>