Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgDangl committed Aug 22, 2022
2 parents 8b58ec0 + 1f9e44f commit 345e4e7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to **LightQuery** are documented here.

## v2.2.2:
- The `PaginationBaseService` in the Angular library now destroys it's subscription internally in the `ngOnDestroy` lifecycle hook

## v2.2.1:
- Added an optional parameter to the LightQuery client for Angular to supply custom query parameters when calling `getAll()`

Expand Down
2 changes: 1 addition & 1 deletion build/.build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageDownload Include="GitVersion.Tool" Version="[5.10.3]" />
<PackageReference Include="Nuke.Common" Version="6.1.2" />
<PackageReference Include="Nuke.Common" Version="6.2.1" />
<PackageReference Include="Nuke.WebDocu" Version="4.0.1" />
<PackageReference Include="Nuke.GitHub" Version="3.0.0" />
<PackageReference Include="ReportGenerator" Version="5.1.9" />
Expand Down
5 changes: 5 additions & 0 deletions src/ng-lightquery/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { EMPTY, Observable, ReplaySubject, Subject, merge, of } from 'rxjs';
import { Injectable, OnDestroy } from '@angular/core';
import {
catchError,
debounceTime,
distinctUntilChanged,
filter,
switchMap,
take,
takeUntil,
} from 'rxjs/operators';

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { PaginationResult } from './pagination-result';

@Injectable()
export abstract class PaginationBaseService<T> {
export abstract class PaginationBaseService<T> implements OnDestroy {
protected paginationResultSource = new ReplaySubject<PaginationResult<T>>(1);
protected lastPaginationResult: PaginationResult<T>;
paginationResult = this.paginationResultSource.asObservable();
private requestUrl = new Subject<string>();
private forceRefreshUrl = new Subject<string>();
private $destroyed = new Subject();

constructor(protected http: HttpClient) {
merge(this.requestUrl.pipe(distinctUntilChanged()), this.forceRefreshUrl)
Expand All @@ -34,7 +36,8 @@ export abstract class PaginationBaseService<T> {
.get<PaginationResult<T>>(url)
.pipe(catchError((_) => EMPTY));
}),
filter((r) => r != null)
filter((r) => r != null),
takeUntil(this.$destroyed)
)
.subscribe(
(result) => {
Expand All @@ -47,6 +50,14 @@ export abstract class PaginationBaseService<T> {
);
}

ngOnDestroy(): void {
this.$destroyed.next();
this.$destroyed.complete();
this.requestUrl.complete();
this.paginationResultSource.complete();
this.forceRefreshUrl.complete();
}

public forceRefresh() {
const url = this.buildUrl();
this.forceRefreshUrl.next(url);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface PaginationResult<T> {
page: number;
pageSize: number;
totalCount: number;
data: T[];
page: number;
pageSize: number;
totalCount: number;
data: T[];
}

0 comments on commit 345e4e7

Please sign in to comment.