I am very new to rxjs and was just wondering is it ok to setup a class property by piping the stream and tapping it, or it should i do it in the subscribe. To me either way
Michael Hladky suggests that you put all side effects in the tap operator and he explains why here.
I think it's generally a good idea to do so, because as Michael says, you can then merge many observables together and create one single subscription for all of them.
I don't know if this improves performance or not, but it definitely makes it easier when you want to unsubscribe to only have one subscription. Unsubscribing is something you always should do to avoid possible memory leaks or other strange behaviors.
Another gain from this approach is that you then easily can pause, resume or complete a group of observables by piping it through operators such as filter or takeWhile, or by switchmapping it through another observable like this:
const allMergedObservables$ = merge(obs1, obs2, obs3);
const play$ = new Subject();
play$.asObservable().pipe(
switchMap(bool => bool ? allMergedObservables$ : EMPTY)
).subscribe();
// Putting 'true' into the play stream activates allMergedObservables$.
play$.next(true);
// Something happens that makes you want to pause the application,
// for instance the user opens the print dialog box,
// so you issue 'false' in the play stream which in turn stops the
// inner subscription of allMergedObservables$:
play$.next(false);
However, it's up to you and whatever programming style you prefer.