title: Call a class method after another has finished its execution
body: <p>I'm trying to execute a class method after another has finished. The first one calls an API and fills an array and a dictionary. Then, the next method takes the data and creates a new dictionary. I cannot make it work sequentially, any idea?</p>
  
  <p>I have tried to add callback when calling the first method, but it ain't working.</p>
  
  <pre><code>this.fillListDictionary(function(){
      this.fillCatDictionary();
  });
  
  fillListDictionary(callback) {
      this._categoryList = [];
      this._propertyDictionary = [];
  
      //Fill list and dictionary calling the API ()
      callback();
  }
  
  fillCatDictionary() {
      this._catDictionary = [];        
      this._categoryList.forEach((category) =&gt; {
          this._propertyDictionary.forEach((property) =&gt; {        
              if(property.properties.includes(category)){
                  var f_index = this._catDictionary.findIndex(x =&gt; x.category == category);
                  if(f_index &gt;= 0){
                      this._catDictionary[f_index].dbIds.push(property.dbId);
                  }
                  else {
                      var cat = new Object();
                      cat.category = category;
                      cat.dbIds = [property.dbId];
                      this._catDictionary.push(cat);
                  }
              }
          })
      })
  }
  
  </code></pre>
  
  <p>I'd like to make it work sequentially: <code>fillCatDictionary</code> has to execute after <code>fillListDictionary</code> has done its job.</p>