Other parts of tree fire events when deepMerge
legaultpierre opened this issue · comments
Hi,
Supposing I have a tree like this:
{
key1: 'value1',
key2: 'value2',
key3: 'value3'
}
If I want to "reset" only some parts of the tree, I could do something like this:
tree.deepMerge({
key2: 'othervalue1',
key3: 'othervalue2'
})
But by doing so, an update event would be fired by key1.
Yet quite logical technically speaking, I wonder if firing event only for merged parts would not fit more the use case.
This makes sense. Unfortunately inner workings of baobab
are not wired to check for this level of precision for performance reasons. Could be done though. Just don't have time to do it. Note that you can sort of implement this yourself on your end by creating a custom function/method that would iterate on target keys and use a .set
or another deepMerge
and emulate what you need. In a sense, deepMerge
is more sugar than anything.
Understood!
Not a real trouble: once my use cased defined, I just had to put some conditions within the update handling function.
Thanks!