I have the following code for an Angular 2 type-ahead component:
this.question["input"] = new FormControl();
this.question["input"].valueChanges
.debounceTime(400)
.switchMap(term => this.question['callback'](term))
.subscribe(
data => {
this.question["options"].length = 0;
this.question["options"].push(...data);
}
);
Which is working great, however I am Attempting to add a loading animation to this event, i.e. an animation starts when the FormControl's value changes, and ends when the data is returned.
With this said is there a way to tap into this method chain with code such as the following?
...
.valueChanges
/* Start Animation or Run Custom Function Here */
.switchMap(term => /* Run AJAX Here */)
.subscribe(
data => {
/* End Animation Here */
}
);
...
Any assistance is appreciated.