ngrx-forms
ngrx-forms copied to clipboard
Pattern: Supply different "feature state" into the form reducer?
trafficstars
Hi there,
first: a thanks for this great library! it really save a lot of tedious work.
Is there a good pattern on how to get the state of another feature (= different ngrx feature module with a form) into the form reducer? I am working on a "rent" calculator which needs certain form values from another (different feature module) form to calculate another form field.
Thanks,
Lee
I would say you can use an effect in between.
- You dispatch an action with the info you currently have in the payload.
- An effect can use
withLatestFromto grab the info you need from the other module. - The effect dispatches a new action with all the that you need (previous payload + state data you just read).
- Form reducer receives the second action and you have all the data you need.