title: How to chain async methods in javascript ES6 classes
body: <p>I want to chain methods from a class.  I have o problems with synchronous methods, but I don't know how to do it with asynchronous methods.</p>
  
  <p>For example, this class:</p>
  
  <pre><code>class Example {
  
    constructor() {
      this.val = 0
    }
  
    async () {
      setTimeout(() =&gt; {
        this.val += 1
        return this
      }, 5000)
    }
  
    sync () {
      this.val += 1
      return this
    }
  
    check () {
      console.log('checker', this.val)
      return this
    }
  
  }
  </code></pre>
  
  <p>This works:</p>
  
  <pre><code>new Example().sync().check()
  &gt; 1
  </code></pre>
  
  <p>But this doesn't work:</p>
  
  <pre><code>new Example().async().check()
  &gt; TypeError: Cannot read property 'check' of undefined
  </code></pre>
  
  <p>P.S. I want chaining, not Hell Callbacks.</p>