@koalarx/ui 13.2.5 → 13.2.8
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/core/esm2020/index.mjs +2 -1
- package/core/esm2020/lib/services/api-requester/koala.api-requester.base.mjs +7 -12
- package/core/esm2020/lib/services/api-requester/koala.api-requester.cache.mjs +29 -11
- package/core/fesm2015/koalarx-ui-core.mjs +35 -21
- package/core/fesm2015/koalarx-ui-core.mjs.map +1 -1
- package/core/fesm2020/koalarx-ui-core.mjs +34 -21
- package/core/fesm2020/koalarx-ui-core.mjs.map +1 -1
- package/core/index.d.ts +1 -0
- package/core/lib/services/api-requester/koala.api-requester.base.d.ts +0 -1
- package/core/lib/services/api-requester/koala.api-requester.cache.d.ts +6 -3
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
|
|
15
15
|
import * as i2$1 from '@angular/router';
|
|
16
16
|
import { NavigationError, NavigationEnd, NavigationCancel, NavigationStart, RouterModule } from '@angular/router';
|
|
17
17
|
import * as i7 from '@angular/material/core';
|
|
18
|
-
import { BehaviorSubject, interval, Observable } from 'rxjs';
|
|
18
|
+
import { BehaviorSubject, interval, Observable, skipWhile } from 'rxjs';
|
|
19
19
|
import jwt from 'jwt-decode';
|
|
20
20
|
import * as i4 from '@koalarx/ui/menu';
|
|
21
21
|
import { menuStateSubject } from '@koalarx/ui/menu';
|
|
@@ -1244,20 +1244,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1244
1244
|
}], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: KoalaOAuth2Service }]; } });
|
|
1245
1245
|
|
|
1246
1246
|
class KoalaApiRequesterCache {
|
|
1247
|
-
static
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
this.cache.push(cache);
|
|
1247
|
+
static createCache(name) {
|
|
1248
|
+
if (!this.hasCache(name)) {
|
|
1249
|
+
this.cache.push({
|
|
1250
|
+
name,
|
|
1251
|
+
data: new BehaviorSubject(undefined)
|
|
1252
|
+
});
|
|
1254
1253
|
}
|
|
1255
1254
|
}
|
|
1256
|
-
static
|
|
1255
|
+
static setDataInCache(name, data) {
|
|
1256
|
+
this.getCacheSubject(name)?.next(data);
|
|
1257
|
+
}
|
|
1258
|
+
static getCacheSubject(name) {
|
|
1257
1259
|
return this.cache.find(item => item.name === name)?.data;
|
|
1258
1260
|
}
|
|
1261
|
+
static getCacheAsObservable(name) {
|
|
1262
|
+
return new Observable(observe => {
|
|
1263
|
+
this.getCacheSubject(name)
|
|
1264
|
+
.pipe(skipWhile(value => value === undefined))
|
|
1265
|
+
.subscribe({
|
|
1266
|
+
next: value => {
|
|
1267
|
+
observe.next(value);
|
|
1268
|
+
observe.complete();
|
|
1269
|
+
},
|
|
1270
|
+
error: err => {
|
|
1271
|
+
observe.error(err);
|
|
1272
|
+
observe.complete();
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1259
1277
|
static hasCache(name) {
|
|
1260
|
-
return !!this.
|
|
1278
|
+
return !!this.getCacheSubject(name);
|
|
1261
1279
|
}
|
|
1262
1280
|
}
|
|
1263
1281
|
KoalaApiRequesterCache.cache = [];
|
|
@@ -1322,23 +1340,18 @@ class KoalaApiRequesterBase {
|
|
|
1322
1340
|
return filter ?? null;
|
|
1323
1341
|
}
|
|
1324
1342
|
request(method, url, data = {}) {
|
|
1325
|
-
this.
|
|
1343
|
+
if (this.enableCache && KoalaApiRequesterCache.hasCache(url)) {
|
|
1344
|
+
return KoalaApiRequesterCache.getCacheAsObservable(url);
|
|
1345
|
+
}
|
|
1346
|
+
KoalaApiRequesterCache.createCache(url);
|
|
1326
1347
|
return this.koalaService
|
|
1327
1348
|
.request(method, url, data)
|
|
1328
1349
|
.pipe(map(response => {
|
|
1329
1350
|
if (this.enableCache)
|
|
1330
|
-
KoalaApiRequesterCache.
|
|
1351
|
+
KoalaApiRequesterCache.setDataInCache(url, response);
|
|
1331
1352
|
return response;
|
|
1332
1353
|
}));
|
|
1333
1354
|
}
|
|
1334
|
-
startCache(endpoint) {
|
|
1335
|
-
if (this.enableCache && KoalaApiRequesterCache.hasCache(endpoint)) {
|
|
1336
|
-
return new Observable(observe => {
|
|
1337
|
-
observe.next(KoalaApiRequesterCache.getCache(endpoint));
|
|
1338
|
-
observe.complete();
|
|
1339
|
-
});
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
1355
|
}
|
|
1343
1356
|
|
|
1344
1357
|
class KoalaRequestService {
|
|
@@ -1436,5 +1449,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1436
1449
|
* Generated bundle index. Do not edit.
|
|
1437
1450
|
*/
|
|
1438
1451
|
|
|
1439
|
-
export { KOALA_LOADER_SUBJECT, KoalaApiRequesterBase, KoalaApiRequesterService, KoalaClientError, KoalaEnvironment, KoalaErrorsHelper, KoalaLanguageHelper, KoalaLoaderService, KoalaNotFoundError, KoalaOAuth2Service, KoalaOauthConfig, KoalaPageModule, KoalaParameterHashLocationStrategy, KoalaRequestHeaderHelper, KoalaRequestService, KoalaResponseFactory, KoalaSuccessError, KoalaTokenService, KoalaUnhautorizedError, LoaderBarPageComponent, NgxKoalaModule, NotificationComponent, PageComponent };
|
|
1452
|
+
export { KOALA_LOADER_SUBJECT, KoalaApiRequesterBase, KoalaApiRequesterCache, KoalaApiRequesterService, KoalaClientError, KoalaEnvironment, KoalaErrorsHelper, KoalaLanguageHelper, KoalaLoaderService, KoalaNotFoundError, KoalaOAuth2Service, KoalaOauthConfig, KoalaPageModule, KoalaParameterHashLocationStrategy, KoalaRequestHeaderHelper, KoalaRequestService, KoalaResponseFactory, KoalaSuccessError, KoalaTokenService, KoalaUnhautorizedError, LoaderBarPageComponent, NgxKoalaModule, NotificationComponent, PageComponent };
|
|
1440
1453
|
//# sourceMappingURL=koalarx-ui-core.mjs.map
|