Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

381
Vistas
Ngrx: How to select two or more properties changes using single selector

I have reactive Form Angular application using NGRX store. Rather than subscribe to entire state want to subscribe some of fields changes e.g. name,city.

I am trying to selectFormNameCity selector but always its subscribing for single properties.

Tried both OR and AND operator condition in selector but not working as expected.

How to achieve using single selector selectFormNameCity for name and city if one of the value changed should get subscribe in component.

Here is the code stackblitz example.

import { createFeatureSelector, createSelector } from '@ngrx/store';

export const selectForm = createFeatureSelector<any>('form');
export const name = createSelector(selectForm, (state) => state.info.name);
export const city = createSelector(selectForm, (state) => state.info.city);

export const selectFormNameCity = createSelector(name, city, (name, city) => {
  return { name, city };
});

Thanks.

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

I didn’t get your use case, but it will work if you change the selector a bit:

export const selectFormNameCity = createSelector(name, city, (name, city) => {
  return {name, city};
});

And it will give you the next output:

{name: "vvvv", city: ""}
{name: "vvvv", city: "123213"}
{name: "44vvvv", city: "123213"}
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda