title: How to wrap an asynchronous function in a promise?
body: <p>I want to wrap an asynchronous function in a promise so that it can run synchronously. I need to do this because I need to retrieve a result that depends on the asynchronous function before continuing with the execution of my program.</p>
  
  <p>Here is my relevant code:</p>
  
  <pre><code>export abstract class OperationElement extends Sprite {
  
      private imagePath;
  
      abstract setPosition(mousePosition?, backgroundHeight?, backgroundWidth?) : void;
  
      loadTexture(){
           var _texture = PIXI.Texture.fromImage(this.imagePath);
           this.texture = _texture;
           console.log(this.height);
      }
  
      setImagePath(path : string){
           this.imagePath = path;
      }
  }
  </code></pre>
  
  <p>The part that runs async is the line <code>var _texture = PIXI.Texture.fromImage(this.imagePath);</code></p>
  
  <p>When the texture is loaded, I can get the height of the texture. I need the height of the texture before I can continue execution of my program. How can I wrap this with a promise so that it runs synchronously?</p>
  
  <p>I've taken a look at some other questions around here, the most relevant had a bunch of downvoted and out of date answers so I shy away from that.</p>