michaelkrone / ngrx-normalizr

Managing normalized state in ngrx applications - transparently
https://michaelkrone.github.io/ngrx-normalizr/
MIT License
50 stars 17 forks source link

Best practice: add nested child #23

Closed tommueller closed 6 years ago

tommueller commented 6 years ago

Hi,

I have a question on best practice of using ngrx-normalizr. If I want to add a child to a deeper nested element, how would you do it?

My element looks like this:

{ "id": "page1", "sections": [{ "id": "section1", "fields": [{ "id": "field1" }] }] }

Now I want to add a new field and of course I have to tell the storage, that I want the new field, within section1, within page1. During updating this is not a problem, since all ids are unique. But when adding I have to tell the store at least the section.

When adding a field using AddAction<Field> it gets added correctly but not linked to any section. How do you solve this in the best way? Adding the field and then linking it to a section? Or basically by taking the section, adding the field to the section and then "updating" the whole section.

Thanks! Tom

michaelkrone commented 6 years ago

Hi @tommueller I am preparing a new release which will have AddChildData and RemoveChildData actions, you might play with them in the current develop branch, will be released with version 2.2.0.

michaelkrone commented 6 years ago

Closing this in favour of #20