I have written a retry mechanism that should return a promise:
private connect(): Promise<any> {
return new Promise((resolve, reject) => {
if(this.count < 4) {
console.log("count < 4, count:"+this.count);
this.count++;
return this.connect();
} else {
resolve("YES");
}
});
}
If I call:
t.connect().then((data:any)=>{ console.log("YES:"+data)});
I would like once count >= 4
and resolve
is called to be able to trigger the above "then".