Apply default merging if the custom merger returns undefined
.
#46
Replies: 3 comments 3 replies
-
I put quite a bit of thought into this when I first added support for custom merging. I decided to require that users must be explicit in what the value should be. Having to hack in a way for users to be able to actually use Another reason is that if a merger function explicitly returns |
Beta Was this translation helpful? Give feedback.
-
@RebeccaStevens Would it be possible to have an easy way to get the appropriate default merger? Something like |
Beta Was this translation helpful? Give feedback.
-
I've put some more thought into this and realized that implicit default merging could quite easily be allowed for via an option. #59 |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to make the custom merge code a bit shorter by not having to have to code the default merging?
So that writing only
return;
would be equal toreturn utils.defaultMergeFunctions.mergeArrays(values);
. Meaning that the lib would apply default merging if the custom merger returnsundefined
. It would make the custom code shorter when not explicitly having to apply the default behavior.Of course we would then also need a way to be able to tell the library explicitly that we want to use
undefined
as the result of the custom merge function. I guess we could do it with a sambol e.g.return utils.useUndefined;
whereuseUndefined
is a symbol coming from the deepmerge lib, so that the lib code could check if the return value of the call of the custom merger is this symbol and then useundefined
as result of the custom merging.Or the custom merger could receive a callback (used like
utils.useUndefined()
) in order to tell the lib that undefined should be used.Originally posted by @NightProgramming in #23 (comment)
Beta Was this translation helpful? Give feedback.
All reactions