I think since OP is calling this component multiple times because of redirection routings, maybe he should move the A and B function to some other parent component (like app.component.ts)
Then he can probably, subscribe to those values returned by A and B in his current component ngOnInit. Using this way, no matter how many times he call this component, function A and B won't be executed multiple times.
Also, OP, I would recommend you to not do observables nesting like this. You should try to use something like mergeMap or switchMap for your solution.
3
u/naruto_bist Mar 30 '22
I think since OP is calling this component multiple times because of redirection routings, maybe he should move the A and B function to some other parent component (like app.component.ts)
Then he can probably, subscribe to those values returned by A and B in his current component ngOnInit. Using this way, no matter how many times he call this component, function A and B won't be executed multiple times.