-
Notifications
You must be signed in to change notification settings - Fork 110
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
Use the FormControlD directly to update a (nested) state? #262
Comments
Not out-of-the-box but you can achieve this by using the const updateByControlId = (state, formControlId, updateFns[]) =>
updateRecursive(
state,
s => s.id === formControlId ?
updateFns.reduce((finalState, updateFn) => updateFn(finalState), s) : s
); |
Indeed, |
Thank you for the quick responses. I came across another way last night and I now wonder if that would be equivalent?
I've tried the |
This is more of a question than a feature or bug report.
Currently I have something like this within my reducer:
I use this pattern often within the reducer to apply multiple updates at the same time to a form control (enable, setValue, markAsDirty...). I therefore do not use the actions provided by ngrx-forms, but my own. However, as soon as the form state contains several nested structures, the dynamic determination of the correct "key" in the respective nested control (here, the attributeKey in the nested 'attributes') becomes quite complex.
Is there a way to apply updates with e.g. 'updateGroup' directly by using just the FormControlID provided by an action that I did not see, yet? Something like
updateGroup<FormValue>(state, formControlID, updateFns[])
?The text was updated successfully, but these errors were encountered: