Skip to content
Snippets Groups Projects
Commit 2e3871da authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6477 7306 listResource bug, missing debounce

parent bd8114dc
No related branches found
No related tags found
No related merge requests found
......@@ -85,23 +85,23 @@ describe('ListResourceService', () => {
isInvalidResourceCombinationSpy = jest.spyOn(ResourceUtil, 'isInvalidResourceCombination').mockReturnValue(true);
});
it('should handle config resource changed', fakeAsync(() => {
it('should handle config resource changed after debounce time', fakeAsync(() => {
service.getList().subscribe();
tick();
tick(300);
expect(service.handleChanges).toHaveBeenCalledWith(listStateResource, baseResource);
}));
it('should handle null configresource', fakeAsync(() => {
it('should handle null configresource after debounce time', fakeAsync(() => {
service.getList().subscribe();
tick();
tick(300);
expect(service.handleNullConfigResource).toHaveBeenCalledWith(baseResource);
}));
it('should call isInvalidResourceCombinationSpy', fakeAsync(() => {
it('should call isInvalidResourceCombinationSpy after debounce time', fakeAsync(() => {
service.getList().subscribe();
tick();
tick(300);
expect(isInvalidResourceCombinationSpy).toHaveBeenCalled();
}));
......
......@@ -23,7 +23,7 @@
*/
import { Resource, ResourceUri, getUrl, hasLink } from '@ngxp/rest';
import { isEqual, isNil, isNull } from 'lodash-es';
import { BehaviorSubject, Observable, combineLatest, filter, first, map, startWith, tap } from 'rxjs';
import { BehaviorSubject, Observable, combineLatest, debounce, filter, first, interval, map, startWith, tap } from 'rxjs';
import { isNotNull, isNotUndefined } from '../tech.util';
import { CreateResourceData, ListItemResource, ListResourceServiceConfig } from './resource.model';
import { ResourceRepository } from './resource.repository';
......@@ -64,6 +64,7 @@ export class ResourceListService<B extends Resource, T extends ListResource, I e
public getList(): Observable<StateResource<T>> {
return combineLatest([this.listResource.asObservable(), this.getConfigResource()]).pipe(
debounce(() => interval(300)),
tap(([stateResource, configResource]) => {
this.handleChanges(stateResource, configResource);
}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment