Run Method on FormControl's valueChanges Event
<p>I have the following code for an Angular 2 type-ahead component:</p>

<pre><code>this.question["input"] = new FormControl();
this.question["input"].valueChanges
        .debounceTime(400)
        .switchMap(term =&gt; this.question['callback'](term))
        .subscribe(
            data =&gt; {
                this.question["options"].length = 0;
                this.question["options"].push(...data);
            }
        );
</code></pre>

<p>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.</p>

<p>With this said is there a way to tap into this method chain with code such as the following?</p>

<pre><code>...
    .valueChanges
    /* Start Animation or Run Custom Function Here */
    .switchMap(term =&gt; /* Run AJAX Here */)
    .subscribe(
        data =&gt; {
            /* End Animation Here */
        }
    );
...
</code></pre>

<p>Any assistance is appreciated.</p>