I'm a beginner with Angular and Javascript, I'm trying to refresh a dashboard. so I use the first one to do the refresh and the second one to stop the refresh. I want to combine these two functions to refresh and stop after a period of time.
let refreshInterval;
function refreshDataSource(){
console.log("going to refresh ..")
refreshInterval= setInterval(() => {
console.log("refreshing ...");
viz.refreshDataAsync();
},3000);
}
function stopdata(){
console.log("stop refresh ...");
clearInterval(refreshInterval);
}
Inside the function refreshDataAsync()
you can call stopdata()
after you are done with your operations.
or you can also await
the function refreshDataAsync()
and then call stopdata()
inside refreshDataSource()
.
How I can use await ?
await refreshDataAsync()
it doesn"t work
try calling
stopdata()
insiderefreshDataAsync()
after updating UI with data.thank u , it works