I am working on implementing debounceTime to allow the user to finish typing before suggestions are generated. I want to give the user the ability to customize how much time is given before suggestions appear. To achieve this, I have added a configuration option in my settings.json file:
{
"EN": {
"workbaskets": {
"time": {
"debounceTime": 750
},
In addition, I have defined an interface in my settings.ts file for exporting it:
import { map } from 'rxjs/operators';
import { OperatorFunction } from 'rxjs';
export interface Customisation {
[language: string]: CustomisationContent;
}
export interface CustomisationContent {
workbaskets?: WorkbasketsCustomisation;
classifications?: ClassificationsCustomisation;
tasks?: TasksCustomisation;
}
export interface WorkbasketsCustomisation {
information?: { owner: LookupField } & CustomFields;
time?: DebounceTime;
'access-items'?: AccessItemsCustomisation;
}
export interface DebounceTime {
debounceTime: number;
}
Now I am facing difficulty assigning the value to debounceTime. In my ngOnInit method, I have tried the following approach (only showing relevant parts of the code):
this.time = this.httpClient.get<DebounceTime>(customisationUrl).pipe(map((data) => {
return data.debounceTime;
})
);
debounceTime(this.time)
I have declared my variable as time: number = 0;
outside of the ngOnInit method.
However, this results in an error: Type 'Observable' is not assignable to type 'number'.
As a newcomer to Angular, I am still learning and struggling to resolve this issue. I have attempted to find solutions by researching existing questions, but with no success. Any guidance or assistance would be greatly appreciated. Since the application already utilizes settings.json and settings.ts, I prefer to continue using this approach for configuring debounceTime and simply need help on how to pass the value as input to the debounceTime function.