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.
For example, this class:
class Example {
  constructor() {
    this.val = 0
  }
  async () {
    setTimeout(() => {
      this.val += 1
      return this
    }, 5000)
  }
  sync () {
    this.val += 1
    return this
  }
  check () {
    console.log('checker', this.val)
    return this
  }
}
This works:
new Example().sync().check()
> 1
But this doesn't work:
new Example().async().check()
> TypeError: Cannot read property 'check' of undefined
P.S. I want chaining, not Hell Callbacks.