Currently, I am working on implementing a simple loader for my search bar to indicate that searching is in progress. My plan was to assign the value "loading" to a variable in the subscribe callback of the valueChanges
observable from my form control and then set it to an empty string in the complete callback. However, I have encountered an issue where the complete callback is never executed.
I also attempted to add a callback using finally on the observable, but unfortunately, this callback is also not being triggered.
The code snippet:
searchBox: Control = new Control();
loadingClass: string = "";
constructor() {
this.searchBox.valueChanges
.debounceTime(400)
.distinctUntilChanged()
.subscribe((text: string) => {
this.imageSearch = text;
this.loadingClass = "loading";
}, (err: Error) => {
console.log(err);
}, () => {
this.loadingClass = "";
console.log("test");
});
}