1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Ngrx: The same selector in multiple components ('parallel')

Discussão em 'Angular' iniciado por Frimlik, Setembro 18, 2025.

  1. Frimlik

    Frimlik Guest

    I've seen somewhere, that it is not recommended to have multiple subscriptions listening to the same stream (Observable) at the same time. Does this apply also to Ngrx selectors?

    My situation: I have a header component and a body component, both with subscription to the same selector (async pipe) and both displayed at the same time. Thus, on both sides I write

    selectedAccount$: Observable<Account> = this.store.select(selectedAccount);


    My question is, whether this approach is possible. From my point of view it should be since selectors are pure functions and they read from identical State (it does not change in the meantime between readings), so they should always return the same result.

    Another approach would be to create a wrapper component, where the selector occurs only once and which passes the resulting value to the nested components, but it's less clear IMO.

    Continue reading...

Compartilhe esta Página