-
Notifications
You must be signed in to change notification settings - Fork 13
Proper way to merge entities #16
Comments
Ok, first things first. You should use the latest beta and take it from there. Secondly, if you deepmerge a normalized entity you need to avoid that the merger function tries to deep merge a proxy reference (e.g. you have a structure like so:
Trying to deepmerge a proxy fails because you will "lose" your Record definition in the process and it gets turned into a Map and you will get all sort of other "strange errors". So, what I do to avoid this is use a little property I added to the Proxy in the latest beta and I use this as a merge function:
Thirdly, if you merge proxied entities and you "touch" the proxy before it is merged into the entity structure, e.g. sorting, you will get an error, because you will touch properties through the proxy that are not in the store yet. So, I merge my entities first and then proceed to process the result. Like so:
/* reducer */ export default function reducer(state = initialState, action = {}) {
[...] HTH |
Hey I'm having some trouble merge entities together, I might be doing something wrong, so wanted to get some feedback here first.
My view loads an initial list with basic information, the view is paginated, when I scroll down, we fetch more items from the backend, which should merge the data to the current state. When I click on an individual item, I will show the basic information, fetch more data in the background for this specific item and merge it to the entities.
I'm having issue with the merge, when I try to mergeDeep I get
collection.update
error.Here's a sample of my code below:
The text was updated successfully, but these errors were encountered: