Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!