Let's take a look at a function that contains the code below:
private foo() {
let obs: Observable<any> = this._http.get<number>('/foo')
obs.subscribe(x=> {
console.log("foo : " + x)
});
this.blah(obs)
}
private blah(obs: Observable<any>) {
obs.subscribe(x => {
console.log("blah : " + x)
})
}
Although this code successfully prints both foo
and blah
, it makes an additional http call to /foo
.
I attempted to fix this issue by substituting the subscribe
method with do
in the blah function, but it did not resolve the problem. What could be causing this behavior?