@ethlete/query 0.1.0-next.4 → 0.1.0-next.5

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.
@@ -891,6 +891,7 @@ const skipPaginationPageParamCalculator = ({ page, itemsPerPage }) => itemsPerPa
891
891
  const INFINITY_QUERY_TOKEN = new InjectionToken('INFINITY_QUERY_TOKEN');
892
892
  class InfinityQueryDirective {
893
893
  constructor() {
894
+ this._queryConfigChanged$ = new Subject();
894
895
  this._viewContext = {
895
896
  $implicit: null,
896
897
  infinityQuery: null,
@@ -916,6 +917,7 @@ class InfinityQueryDirective {
916
917
  return this._infinityQuery;
917
918
  }
918
919
  set infinityQuery(v) {
920
+ this._cleanup();
919
921
  this._infinityQuery = v;
920
922
  this._infinityQueryInstance = this._setupInfinityQuery(v);
921
923
  this._loadNextPage();
@@ -982,14 +984,14 @@ class InfinityQueryDirective {
982
984
  this._data$.next([]);
983
985
  }
984
986
  this._cdr.markForCheck();
985
- }), takeUntil(this._destroy$))
987
+ }), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
986
988
  .subscribe();
987
989
  instance.data$
988
990
  .pipe(tap((data) => {
989
991
  this._viewContext.infinityQuery = this._viewContext.$implicit = data;
990
992
  this._data$.next(data);
991
993
  this._cdr.markForCheck();
992
- }), takeUntil(this._destroy$))
994
+ }), takeUntil(this._destroy$), takeUntil(this._queryConfigChanged$))
993
995
  .subscribe();
994
996
  return instance;
995
997
  }
@@ -1005,14 +1007,29 @@ class InfinityQueryDirective {
1005
1007
  this._viewContainerRef.createEmbeddedView(this._mainTemplateRef, this._viewContext);
1006
1008
  }
1007
1009
  }
1010
+ _cleanup() {
1011
+ this._queryConfigChanged$.next(true);
1012
+ this.instance?._destroy();
1013
+ this._viewContext.loading = false;
1014
+ this._viewContext.error = null;
1015
+ this._viewContext.infinityQuery = null;
1016
+ this._viewContext.$implicit = null;
1017
+ this._viewContext.isFirstLoad = false;
1018
+ this._viewContext.canLoadMore = false;
1019
+ this._viewContext.currentPage = null;
1020
+ this._viewContext.itemsPerPage = null;
1021
+ this._viewContext.totalPages = null;
1022
+ this._data$.next([]);
1023
+ }
1008
1024
  }
1009
1025
  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 });
1026
+ 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
1027
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.9", ngImport: i0, type: InfinityQueryDirective, decorators: [{
1012
1028
  type: Directive,
1013
1029
  args: [{
1014
1030
  // eslint-disable-next-line @angular-eslint/directive-selector
1015
1031
  selector: '[infinityQuery]',
1032
+ exportAs: 'infinityQuery',
1016
1033
  standalone: true,
1017
1034
  providers: [{ provide: INFINITY_QUERY_TOKEN, useExisting: InfinityQueryDirective }],
1018
1035
  }]