-2

How do I access the this class object inside a Promise object?

class MyClass{

    constructor(){
        this.value = null;
    }

    get_value(){
        var promise = new Promise(function(resolve, reject){
            (function wait_(){
                if(this.value){ // <------- how to access "this" class object here?
                    return resolve();
                }
                setTimeout(wait_, 1000);
            })
        }
    }
}
alvrm
  • 121
  • 8

0 Answers0