I am looking for an elegant way to break out of this poll:
private pollLinkResult() {
(function poll() {
setTimeout(() => {
//call the service layer to do an ajax call
//depending on the result I would like to exit the infinite poll
}, 1000);
})();
}
Any ideas?
private pollLinkResult() {
(function poll() {
let myTimeout = setTimeout(() => {
//call the service layer to do an ajax call
//depending on the result I would like to exit the infinite poll
if(yourCondition){
clearTimeout(myTimeout);
}
}, 1000);
})();
}