-
Notifications
You must be signed in to change notification settings - Fork 13
How to handle merge entity records into NormalizedRecord? #7
Comments
Thanks. I'll take your remarks and add them to the test (feel free to do that, if you like). |
Thinking about this a bit more, this is likely caused by the fact that the entities structure is a record and I basically abuse the Record api by creating the Record definition with the entities result. This seemed like a good idea at the time to be able to keep the ability for dot-property access in place. This is an unwanted side effect. The most obvious workaround instead of merging is to create a new Record with the content of the original record and the new result. I suppose I could create a helper for that. Another option would be to drop this Record approach entirely and use a map, which is the proper way of doing this, but at the expense of dot-property access. |
I just had an idea. What if the result key would contain proxies instead of ids? In that case, you would never have to access entities directly and the entities structure could be just be based on a regular map. Alternatively, even if we don't do that, the relation could be like so, and you could merge on the Record schema keys.
If you use the proxy, this would be minimally impactful on your code. The proxy would abstract the map access away mostly. I imagine it might also be more performant.
//would become
I think I will make this an option, so people can choose between the approaches. WDYT? |
Ok, added to 0.0.3-rc branch |
Though I am not currently using getState/reducerKey, that seems like a viable solution. |
NormalizedRecord cannot be merged with previous entities, records are replaced and not merged together as one would expect. Using mergeDeep (which would handle list concatenation) throws an error as entities is a Record and not a List.
The text was updated successfully, but these errors were encountered: