@@ -19,27 +19,22 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
19
19
private ds ?: ListValue ;
20
20
private attributeId ?: ListAttributeValue [ "id" ] ;
21
21
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 ;
25
24
26
25
constructor (
27
26
caption : CaptionsProvider ,
28
- protected valuesMap : Map < string , ObjectItem >
27
+ protected valuesMap : Map < string , ObjectItem > ,
28
+ filterInputDebounceInterval : number = 200
29
29
) {
30
30
super ( caption ) ;
31
- this . createDebouncedSetFilter ( ) ;
32
- }
33
-
34
- private createDebouncedSetFilter ( ) : void {
35
- this . cleanup ( ) ;
31
+ this . filterInputDebounceInterval = filterInputDebounceInterval ;
36
32
37
- const [ debouncedFn , abort ] = debounce ( ( filterCondition : FilterCondition | undefined ) => {
33
+ const [ debouncedFn ] = debounce ( ( filterCondition : FilterCondition | undefined ) => {
38
34
this . ds ?. setFilter ( filterCondition ) ;
39
35
} , this . filterInputDebounceInterval ) ;
40
36
41
37
this . debouncedSetFilter = debouncedFn ;
42
- this . abortDebouncedFilter = abort ;
43
38
}
44
39
45
40
get sortOrder ( ) : SortOrder {
@@ -69,10 +64,10 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
69
64
getAll ( ) : string [ ] {
70
65
if ( this . lazyLoading && this . attributeId ) {
71
66
if ( this . searchTerm === "" ) {
72
- this . debouncedSetFilter ! ( undefined ) ;
67
+ this . debouncedSetFilter ( undefined ) ;
73
68
} else {
74
69
const filterCondition = datasourceFilter ( this . filterType , this . searchTerm , this . attributeId ) ;
75
- this . debouncedSetFilter ! ( filterCondition ) ;
70
+ this . debouncedSetFilter ( filterCondition ) ;
76
71
}
77
72
78
73
return this . options ;
@@ -118,12 +113,6 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
118
113
this . filterType = props . filterType ;
119
114
this . lazyLoading = props . lazyLoading ;
120
115
121
- const newInterval = props . filterInputDebounceInterval ?? 200 ;
122
- if ( newInterval !== this . filterInputDebounceInterval ) {
123
- this . filterInputDebounceInterval = newInterval ;
124
- this . createDebouncedSetFilter ( ) ;
125
- }
126
-
127
116
if ( this . lazyLoading ) {
128
117
if ( props . ds . status === "loading" ) {
129
118
this . loading = true ;
@@ -137,10 +126,4 @@ export class BaseDatasourceOptionsProvider extends BaseOptionsProvider<ObjectIte
137
126
items . forEach ( i => this . valuesMap . set ( i . id , i ) ) ;
138
127
this . options = Array . from ( this . valuesMap . keys ( ) ) ;
139
128
}
140
-
141
- cleanup ( ) : void {
142
- if ( this . abortDebouncedFilter ) {
143
- this . abortDebouncedFilter ( ) ;
144
- }
145
- }
146
129
}
0 commit comments