Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern: Supply different "feature state" into the form reducer? #284

Open
mostl33 opened this issue Jun 23, 2022 · 1 comment
Open

Pattern: Supply different "feature state" into the form reducer? #284

mostl33 opened this issue Jun 23, 2022 · 1 comment

Comments

@mostl33
Copy link

mostl33 commented Jun 23, 2022

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

@mostl33 mostl33 changed the title Pettern: Supply different "feature state" into the form reducer? Pattern: Supply different "feature state" into the form reducer? Jun 23, 2022
@Balastrong
Copy link

I would say you can use an effect in between.

  1. You dispatch an action with the info you currently have in the payload.
  2. An effect can use withLatestFrom to grab the info you need from the other module.
  3. The effect dispatches a new action with all the that you need (previous payload + state data you just read).
  4. Form reducer receives the second action and you have all the data you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants