To be honest, I'm not even sure this is an issue, but I'm curious about sharing my observables when using ngrx. Let's say you have these three variables in your store that control whether something is open or expanded:
export interface State {
isSidebarActive: boolean;
isPlaylistExpanded: boolean;
isFolderListExpanded: boolean;
}
If you return all three variables with a single selector, you might end up with the same variable being used multiple times in your template. This isn't actual code, so bear with me:
<div [hidden]="!(uiState$ | async)?.isSidebarActive">
<ul [@expand]="(uiState$ | async)?.isPlaylistExpanded">
<li></li>
</ul>
<ul [@expand]="(uiState$ | async)?.isFolderListExpanded">
<li></li>
</ul>
</div>
From what I understand, this will create three unique subscriptions to uiState$, and you can use the .share() operator to share one subscription to all three items. If this is necessary, where would you share your Observable? Here?
constructor(private store: Store<fromRoot.State>) {
this.uiState$ = this.store.select(fromRoot.getUiState).share();
}
Looking at this answer, I'm not even sure it is necessary.
TIA.