Limit pushing of filter updates in filter service
Limits the pushing updateFilteredData in the baseFilterList service to only listen for actual changes of the list input data This should decrease client stress on autoupdates
This commit is contained in:
parent
136e0a0569
commit
15fb19ad2f
@ -1,4 +1,5 @@
|
|||||||
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
|
||||||
|
import { distinctUntilChanged } from 'rxjs/operators';
|
||||||
|
|
||||||
import { BaseModel } from 'app/shared/models/base/base-model';
|
import { BaseModel } from 'app/shared/models/base/base-model';
|
||||||
import { BaseRepository } from '../repositories/base-repository';
|
import { BaseRepository } from '../repositories/base-repository';
|
||||||
@ -182,7 +183,20 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
|
|||||||
this.inputDataSubscription.unsubscribe();
|
this.inputDataSubscription.unsubscribe();
|
||||||
this.inputDataSubscription = null;
|
this.inputDataSubscription = null;
|
||||||
}
|
}
|
||||||
this.inputDataSubscription = inputData.subscribe(data => {
|
this.inputDataSubscription = inputData
|
||||||
|
/**
|
||||||
|
* Every autoupdate pushes data here.
|
||||||
|
* Not entirely sure why this happens.
|
||||||
|
* However, we are only concerned about changes to our
|
||||||
|
* current moddels, so compare the changes should
|
||||||
|
* limit the updating of filters
|
||||||
|
*/
|
||||||
|
.pipe(
|
||||||
|
distinctUntilChanged((curr, prev) => {
|
||||||
|
return curr.length === prev.length && curr.every((v, i) => v === prev[i]);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe(data => {
|
||||||
this.inputData = data;
|
this.inputData = data;
|
||||||
this.updateFilteredData();
|
this.updateFilteredData();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user