@ethlete/query 0.1.0-next.4 → 0.1.0-next.6
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/esm2020/lib/directives/infinity-query.directive.mjs +21 -4
- package/esm2020/lib/infinite-query/infinity-query.types.mjs +1 -1
- package/esm2020/lib/query/query.mjs +6 -2
- package/esm2020/lib/utils/deep-freeze.util.mjs +5 -1
- package/fesm2015/ethlete-query.mjs +30 -4
- package/fesm2015/ethlete-query.mjs.map +1 -1
- package/fesm2020/ethlete-query.mjs +29 -4
- package/fesm2020/ethlete-query.mjs.map +1 -1
- package/lib/directives/infinity-query.directive.d.ts +3 -1
- package/lib/infinite-query/infinity-query.types.d.ts +5 -2
- package/lib/utils/deep-freeze.util.d.ts +1 -1
- package/package.json +1 -1
|
@@ -408,6 +408,10 @@ const gql = (strings, ...values) => {
|
|
|
408
408
|
};
|
|
409
409
|
|
|
410
410
|
const deepFreeze = (object) => {
|
|
411
|
+
// check if object is actually an object or frozen
|
|
412
|
+
if (!object || typeof object !== 'object' || Object.isFrozen(object)) {
|
|
413
|
+
return object;
|
|
414
|
+
}
|
|
411
415
|
// Retrieve the property names defined on object
|
|
412
416
|
const propNames = Object.getOwnPropertyNames(object);
|
|
413
417
|
// Freeze properties before freezing self
|
|
@@ -570,7 +574,11 @@ class Query {
|
|
|
570
574
|
const isResponseObject = typeof response === 'object';
|
|
571
575
|
const isGql = isGqlQueryConfig(this._queryConfig);
|
|
572
576
|
let responseData = null;
|
|
573
|
-
if (isGql &&
|
|
577
|
+
if (isGql &&
|
|
578
|
+
isResponseObject &&
|
|
579
|
+
!!response.data &&
|
|
580
|
+
typeof response.data === 'object' &&
|
|
581
|
+
'data' in response.data) {
|
|
574
582
|
responseData = response.data['data'];
|
|
575
583
|
}
|
|
576
584
|
else {
|
|
@@ -891,6 +899,7 @@ const skipPaginationPageParamCalculator = ({ page, itemsPerPage }) => itemsPerPa
|
|
|
891
899
|
const INFINITY_QUERY_TOKEN = new InjectionToken('INFINITY_QUERY_TOKEN');
|
|
892
900
|
class InfinityQueryDirective {
|
|
893
901
|
constructor() {
|
|
902
|
+
this._queryConfigChanged$ = new Subject();
|
|
894
903
|
this._viewContext = {
|
|
895
904
|
$implicit: null,
|
|
896
905
|
infinityQuery: null,
|
|
@@ -916,6 +925,7 @@ class InfinityQueryDirective {
|
|
|
916
925
|
return this._infinityQuery;
|
|
917
926
|
}
|
|
918
927
|
set infinityQuery(v) {
|
|
928
|
+
this._cleanup();
|
|
919
929
|
this._infinityQuery = v;
|
|
920
930
|
this._infinityQueryInstance = this._setupInfinityQuery(v);
|
|
921
931
|
this._loadNextPage();
|
|
@@ -982,14 +992,14 @@ class InfinityQueryDirective {
|
|
|
982
992
|
this._data$.next([]);
|
|
983
993
|
}
|
|
984
994
|
this._cdr.markForCheck();
|
|
985
|
-
}), takeUntil(this._destroy$))
|
|
995
|
+
}), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
|
|
986
996
|
.subscribe();
|
|
987
997
|
instance.data$
|
|
988
998
|
.pipe(tap((data) => {
|
|
989
999
|
this._viewContext.infinityQuery = this._viewContext.$implicit = data;
|
|
990
1000
|
this._data$.next(data);
|
|
991
1001
|
this._cdr.markForCheck();
|
|
992
|
-
}), takeUntil(this._destroy$))
|
|
1002
|
+
}), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
|
|
993
1003
|
.subscribe();
|
|
994
1004
|
return instance;
|
|
995
1005
|
}
|
|
@@ -1005,14 +1015,29 @@ class InfinityQueryDirective {
|
|
|
1005
1015
|
this._viewContainerRef.createEmbeddedView(this._mainTemplateRef, this._viewContext);
|
|
1006
1016
|
}
|
|
1007
1017
|
}
|
|
1018
|
+
_cleanup() {
|
|
1019
|
+
this._queryConfigChanged$.next(true);
|
|
1020
|
+
this.instance?._destroy();
|
|
1021
|
+
this._viewContext.loading = false;
|
|
1022
|
+
this._viewContext.error = null;
|
|
1023
|
+
this._viewContext.infinityQuery = null;
|
|
1024
|
+
this._viewContext.$implicit = null;
|
|
1025
|
+
this._viewContext.isFirstLoad = false;
|
|
1026
|
+
this._viewContext.canLoadMore = false;
|
|
1027
|
+
this._viewContext.currentPage = null;
|
|
1028
|
+
this._viewContext.itemsPerPage = null;
|
|
1029
|
+
this._viewContext.totalPages = null;
|
|
1030
|
+
this._data$.next([]);
|
|
1031
|
+
}
|
|
1008
1032
|
}
|
|
1009
1033
|
InfinityQueryDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1010
|
-
InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.9", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], ngImport: i0 });
|
|
1034
|
+
InfinityQueryDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.2.9", type: InfinityQueryDirective, isStandalone: true, selector: "[infinityQuery]", inputs: { infinityQuery: "infinityQuery" }, providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }], exportAs: ["infinityQuery"], ngImport: i0 });
|
|
1011
1035
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryDirective, decorators: [{
|
|
1012
1036
|
type: Directive,
|
|
1013
1037
|
args: [{
|
|
1014
1038
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
1015
1039
|
selector: '[infinityQuery]',
|
|
1040
|
+
exportAs: 'infinityQuery',
|
|
1016
1041
|
standalone: true,
|
|
1017
1042
|
providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }],
|
|
1018
1043
|
}]
|