Default an observable is not multicast enabled. This means that multiple subscriptions will generate their own stream. Since you do not want to have to re-fetch the authentication credentials per subscription you need to make your original stream multicast-compatible. This is done using for example the share()
operator, which will make the stream hot upon the first subscription and internally stores a refcount for all following subscriptions.
Since subscriptions which are late to the party will not automatically get the previous emitted values when the stream became hot we need to build in functionality to replay emitted values.
Both of these requirements are combined in the shareReplay()
operator which lets your multicast the latest n values.
So your code would look like this:
const authStream = this.authService.auth$.shareReplay(1);
// component 1
const myAuthDisposable = authStream.subscribe(auth => this.auth = auth)
// component 2
const myAuthDisposable = authStream.subscribe(auth => this.auth = auth)