@gudhub/core 1.0.69 → 1.1.3

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.
@@ -16,7 +16,6 @@ export class GudHubHttpsService {
16
16
  // Here we set a function to get token
17
17
  init(getToken) {
18
18
  this.getToken = getToken;
19
- this.promiseCollector(5000);
20
19
  }
21
20
 
22
21
 
@@ -52,10 +51,9 @@ export class GudHubHttpsService {
52
51
  });
53
52
 
54
53
  });
55
- this.requestPromises[hesh] = {
56
- promise,
57
- time: Date.now()
58
- }
54
+
55
+ this.pushPromise(promise, hesh);
56
+
59
57
  return promise;
60
58
  }
61
59
 
@@ -82,10 +80,9 @@ export class GudHubHttpsService {
82
80
  });
83
81
 
84
82
  });
85
- this.requestPromises[hesh] = {
86
- promise,
87
- time: Date.now()
88
- }
83
+
84
+ this.pushPromise(promise, hesh);
85
+
89
86
  return promise;
90
87
  }
91
88
 
@@ -118,10 +115,9 @@ export class GudHubHttpsService {
118
115
  reject(error);
119
116
  });
120
117
  });
121
- this.requestPromises[hesh] = {
122
- promise,
123
- time: Date.now()
124
- }
118
+
119
+ this.pushPromise(promise, hesh);
120
+
125
121
  return promise;
126
122
  }
127
123
 
@@ -154,11 +150,30 @@ export class GudHubHttpsService {
154
150
  });
155
151
 
156
152
  });
153
+
154
+ this.pushPromise(promise, hesh);
155
+
156
+ return promise;
157
+ }
158
+
159
+ /*************** PUSH PROMISE ***************/
160
+ // It push promise object by hash to this.requestPromises
161
+
162
+ pushPromise(promise, hesh) {
157
163
  this.requestPromises[hesh] = {
158
164
  promise,
159
- time: Date.now()
165
+ hesh,
166
+ callback: promise.then(() => {
167
+ this.destroyPromise(hesh);
168
+ })
160
169
  }
161
- return promise;
170
+ }
171
+
172
+ /*************** DELETE PROMISE ***************/
173
+ // It deletes promise from this.requestPromises by hash after promise resolve
174
+
175
+ destroyPromise(hesh) {
176
+ this.requestPromises = this.requestPromises.filter(request => request.hesh !== hesh)
162
177
  }
163
178
 
164
179
 
@@ -177,21 +192,4 @@ export class GudHubHttpsService {
177
192
  }
178
193
  return "h" + hash;
179
194
  }
180
-
181
-
182
- //********************* PROMICE COLLECTOR ***********************//
183
- // Here we erace all promicess after period of time
184
- // !!! Some modifications needed here, probably erace promicec those were resolved or save start time and erace it in a minute after promice created
185
- promiseCollector( interval ) {
186
- setInterval(() => {
187
- Object.keys(this.requestPromises).forEach(hesh => {
188
- if(Date.now() - this.requestPromises[hesh].time > interval ){
189
- delete this.requestPromises[hesh];
190
- }
191
- });
192
-
193
- //console.log("promises:", Object.keys(this.requestPromises).length);
194
- }, interval);
195
- }
196
-
197
195
  }
package/GUDHUB/gudhub.js CHANGED
@@ -29,7 +29,7 @@ export class GudHub {
29
29
  file_server_url: ''
30
30
  }
31
31
  ) {
32
- this.ghconstructor = new GHConstructor();
32
+ this.ghconstructor = new GHConstructor(this);
33
33
  this.interpritate = new Interpritate(this);
34
34
  this.pipeService = new PipeService();
35
35
  this.storage = new Storage(options.async_modules_path, options.file_server_url);
@@ -146,12 +146,6 @@ export class GudHub {
146
146
  );
147
147
  }
148
148
 
149
- /******************* INIT ANGULAR INJECTOR *******************/
150
-
151
- initAngularInjector(injector) {
152
- return this.ghconstructor.initAngularInjector(injector);
153
- }
154
-
155
149
  /******************* INTERPRITATE *******************/
156
150
 
157
151
  getInterpretation(value, field, dataType, source, itemId, appId, containerId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.0.69",
3
+ "version": "1.1.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {