typescript - Execute a promise until a condition is met (within a while loop) -
i want encapsulate promise within while loop, method executed until condition met. i've tried implement this, end infinite promises generated until stack overflow occurs.
i want implement following in typescript:
while (responsesuccess === false) { myclass.executescript.then((thiswassuccessful: boolean) => { responsesuccess = thiswassuccessful; });
i know little unconventional, script have created request server application executes. not return success first time, or n times (not can change).
try use await operator.
while (responsesuccess === false) { responsesuccess = await myclass.executescript; });
ps: should use ts 2.1 or higher target es5
Comments
Post a Comment