Angular state management with NgRx

Using custom selectors for one-to-one or one-to-many data relationships.

Credit to

When implementing state management with Ngrx we often have a predefined API that can not be changed. I ran across a business case: back end API is written in a way where 2 sets of data that are returned are depend on the other. One-to-one or one-to-many relationship. In order to map entities with corresponding ids we have to create a custom selector.

To make a selector that will do a lookup of another selector just add 4 Actions, 2 Effects and 3 selectors:

This is a declaration of the 4 Actions

This is an implementation of the 2 effects

When declaring selectors you have to remember that order of loaded data is not predictable and we have to account for it not all being loaded yet:

See my github repository for a work-in-progress project I am working on to support elementary school events for my children’s’ school.

To see the working (wip) site visit:

Originally published at on September 3, 2019.

sharing knowledge, encouraging to learn, promoting passion for coding, supporting mothers who code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store