You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im running into a difficult issue to solve because I need to create a custom merge for a single key "quantity" where the value is just a number, such that each time the objects are merged, the quantity values are added.
Which works to add SOME of the quantities (which are placed in multiple levels of the object), however it has been a nightmare trying to get it to ignore all other number values for some reason. Either way its a major performance issue to convert all number values in these large objects over to mergeable objects only to ignore them inside the customMerge function.
Is there a clever way to accomplish this I am not seeing? The best solution I can think of would be if I could access the keys within the isMergeableObject function like this
It's a little awkward, but seems less scary to me than making isMergeableObject aware of keys or making customMerge aware of values, which seems conceptually fraught.
Saying "this merge function handles numbers" and then making a custom merge that says "numbers are merged by just taking the value from the source object, unless we're talking about quantity" feels reasonable.
Great piece of code! Its been a great help.
Im running into a difficult issue to solve because I need to create a custom merge for a single key "quantity" where the value is just a number, such that each time the objects are merged, the quantity values are added.
ive tried this
Which works to add SOME of the quantities (which are placed in multiple levels of the object), however it has been a nightmare trying to get it to ignore all other number values for some reason. Either way its a major performance issue to convert all number values in these large objects over to mergeable objects only to ignore them inside the customMerge function.
Is there a clever way to accomplish this I am not seeing? The best solution I can think of would be if I could access the keys within the isMergeableObject function like this
The text was updated successfully, but these errors were encountered: