Currently, I'm in the process of enhancing my code by utilizing merge map to call an observable within another observable.
Although the existing code functions properly, I recognize that it's not considered best practice. As a result, I am attempting to refactor it.
this._headerRefresh$.pipe(debounceTime(this.debounceTime)).subscribe(data => {
this._outputProvider
.getData(this.to.url, this.to.body ? this.to.body : undefined)
.pipe(
debounceTime(this.debounceTime),
)
.subscribe(res => {
this.setstuff(res);
});
});
I attempted to refactor the code in the following manner, however, it appears that the 'this.setstuff(res)' is not being called as expected:
this._headerRefresh$
.pipe(
debounceTime(this.debounceTime),
mergeMapTo(
this._outputProvider
.getData(this.to.url, this.to.body ? this.to.body : undefined)
),
)
.subscribe(res => {
console.log(res);
this.setstuff(res);
});
Could there be something crucial that I have overlooked?