Josh Hicks
1 min readNov 23, 2019

--

Hi Jared,

Stores and Forms are a very tricky thing to pair together. If you’re using NGXS I recommend checking our their awesome plugin https://www.ngxs.io/plugins/form. They list some examples that would remove the need to manually normalize/denormalize your data. Also, in general, that can be an expensive process so you want to do it as little as possible.

If you’re using NGRX then I wouldn’t put the form in the store at all. They don’t recommend mixing the two since the store maintains its own state and has its own API for watching for changes. Plus, you’ll run into the normalization issues you mentioned. Instead, I would keep the form in a facade service that is injected in the main smart container component. Then you will have your form persisted but you won’t have to deal with the headaches of putting the round peg (form) into a square hole (Store).

Hope that helps

--

--

Josh Hicks
Josh Hicks

Written by Josh Hicks

Software engineer, writer, traveler, weight lifter

Responses (1)