@@ -19,27 +19,22 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
1919 private ds ?: ListValue ;
2020 private attributeId ?: ListAttributeValue [ "id" ] ;
2121 protected loading : boolean = false ;
22- private debouncedSetFilter ! : ( filterCondition : FilterCondition | undefined ) => void ;
23- private abortDebouncedFilter ! : ( ) => void ;
24- private filterInputDebounceInterval : number = 200 ;
22+ private debouncedSetFilter : ( filterCondition : FilterCondition | undefined ) => void ;
23+ private filterInputDebounceInterval : number ;
2524
2625 constructor (
2726 caption : CaptionsProvider ,
28- protected valuesMap : Map < string , ObjectItem >
27+ protected valuesMap : Map < string , ObjectItem > ,
28+ filterInputDebounceInterval : number = 200
2929 ) {
3030 super ( caption ) ;
31- this . createDebouncedSetFilter ( ) ;
32- }
33-
34- private createDebouncedSetFilter ( ) : void {
35- this . cleanup ( ) ;
31+ this . filterInputDebounceInterval = filterInputDebounceInterval ;
3632
37- const [ debouncedFn , abort ] = debounce ( ( filterCondition : FilterCondition | undefined ) => {
33+ const [ debouncedFn ] = debounce ( ( filterCondition : FilterCondition | undefined ) => {
3834 this . ds ?. setFilter ( filterCondition ) ;
3935 } , this . filterInputDebounceInterval ) ;
4036
4137 this . debouncedSetFilter = debouncedFn ;
42- this . abortDebouncedFilter = abort ;
4338 }
4439
4540 get sortOrder ( ) : SortOrder {
@@ -69,10 +64,10 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
6964 getAll ( ) : string [ ] {
7065 if ( this . lazyLoading && this . attributeId ) {
7166 if ( this . searchTerm === "" ) {
72- this . debouncedSetFilter ! ( undefined ) ;
67+ this . debouncedSetFilter ( undefined ) ;
7368 } else {
7469 const filterCondition = datasourceFilter ( this . filterType , this . searchTerm , this . attributeId ) ;
75- this . debouncedSetFilter ! ( filterCondition ) ;
70+ this . debouncedSetFilter ( filterCondition ) ;
7671 }
7772
7873 return this . options ;
@@ -122,12 +117,6 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
122117 this . filterType = props . filterType ;
123118 this . lazyLoading = props . lazyLoading ;
124119
125- const newInterval = props . filterInputDebounceInterval ?? 200 ;
126- if ( newInterval !== this . filterInputDebounceInterval ) {
127- this . filterInputDebounceInterval = newInterval ;
128- this . createDebouncedSetFilter ( ) ;
129- }
130-
131120 if ( this . lazyLoading ) {
132121 if ( props . ds . status === "loading" ) {
133122 this . loading = true ;
@@ -141,10 +130,4 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
141130 items . forEach ( i => this . valuesMap . set ( i . id , i ) ) ;
142131 this . options = Array . from ( this . valuesMap . keys ( ) ) ;
143132 }
144-
145- cleanup ( ) : void {
146- if ( this . abortDebouncedFilter ) {
147- this . abortDebouncedFilter ( ) ;
148- }
149- }
150133}
0 commit comments