@imposium-hub/components 1.36.1 → 1.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imposium-hub/components",
3
- "version": "1.36.1",
3
+ "version": "1.36.2",
4
4
  "description": "React & Typescript component / asset library for Imposium front-ends",
5
5
  "main": "dist/components.js",
6
6
  "scripts": {
package/services/API.ts CHANGED
@@ -66,6 +66,7 @@ export interface IImposiumAPI {
66
66
  getSystemMetrics(storyId : string, start : number, end : number, step : number, alias : string);
67
67
  getOrganizations();
68
68
  addOrganization(orgName : string);
69
+ cancelExperiencePolling();
69
70
  }
70
71
 
71
72
  interface ICancelTokenCache {
@@ -78,7 +79,7 @@ export default class API {
78
79
  private http : AxiosInstance;
79
80
  private awsHttp : AxiosInstance;
80
81
  private pollingInterval : number = 1000;
81
-
82
+ private pollTimer : any;
82
83
  private cancelTokenCache : ICancelTokenCache = {
83
84
  player: undefined,
84
85
  system: undefined
@@ -695,7 +696,6 @@ export default class API {
695
696
  }
696
697
 
697
698
  private poll(config, resolve, reject, allowEmpty = true) {
698
-
699
699
  this.http(config)
700
700
  .then((res : AxiosResponse) => {
701
701
 
@@ -706,7 +706,7 @@ export default class API {
706
706
  resolve(res.data);
707
707
  } else {
708
708
  if (isObjEmpty(res.data.output)) {
709
- setTimeout(() => {
709
+ this.pollTimer = setTimeout(() => {
710
710
  this.poll(config, resolve, reject, allowEmpty);
711
711
  }, this.pollingInterval);
712
712
  } else {
@@ -714,7 +714,7 @@ export default class API {
714
714
  }
715
715
  }
716
716
  } else {
717
- setTimeout(() => {
717
+ this.pollTimer = setTimeout(() => {
718
718
  this.poll(config, resolve, reject, allowEmpty);
719
719
  }, this.pollingInterval);
720
720
  }
@@ -724,6 +724,13 @@ export default class API {
724
724
  });
725
725
  }
726
726
 
727
+ public cancelExperiencePolling() : Promise<void> {
728
+ return new Promise((resolve) => {
729
+ clearTimeout(this.pollTimer);
730
+ resolve();
731
+ });
732
+ }
733
+
727
734
  public getJobLogUrl = (jobId : string) : Promise<any | Error> => {
728
735
 
729
736
  const route = `/job/${jobId}/log-url`;