mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 06:24:03 +00:00
Vue Polling - Code sycn with fixes from Shipping Portal (dillon/51-vue-polling-experimental-1)
This commit is contained in:
@@ -135,15 +135,34 @@
|
||||
this.isPolling = false;
|
||||
// this.isLoading = false;
|
||||
},
|
||||
startPolling(jobId) {
|
||||
// this.fetchJobResult(jobId); // Start immediately
|
||||
this.pollingInterval = setInterval(() => {
|
||||
startPolling(jobId, maxAttempts = 3) {
|
||||
let attempts = 0;
|
||||
const pollJobResult = () => {
|
||||
if (this.isPolling) {
|
||||
return;
|
||||
}
|
||||
this.isPolling = true;
|
||||
this.fetchJobResult(jobId); // Replace with the actual job ID
|
||||
}, 10000); // Poll every 5 seconds
|
||||
|
||||
attempts++;
|
||||
|
||||
if (attempts > maxAttempts) {
|
||||
clearInterval(this.pollingInterval);
|
||||
this.pollingInterval = null;
|
||||
this.isPolling = false;
|
||||
this.isLoading = false;
|
||||
console.log(`Reached maximum attempts (${maxAttempts}). Polling stopped.`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.fetchJobResult(jobId);
|
||||
};
|
||||
|
||||
// Initial call
|
||||
// pollJobResult();
|
||||
|
||||
// Set up polling interval
|
||||
this.pollingInterval = setInterval(pollJobResult, 10000);
|
||||
|
||||
},
|
||||
stopPolling() {
|
||||
clearInterval(this.pollingInterval);
|
||||
|
||||
Reference in New Issue
Block a user