Open sapryniukt opened 2 years ago
@sapryniukt Thanks for the PR! Is this structure useful for you? If you try and access address.country.id
to see what the value is, now you need to do something like address.country[VALUE].id
. Is that ok?
@snewcomer Yep! As I understand it, snapshot()
is only used for restore()
therefore, changeset after restore will have the expected result. The problem is that keys are nested objects and values can also be objects. Especially for the condition of exit from recursion it is necessary to separate which objects are keys and which values.
the idea was to make something like address.country[VALUE].id
.
Do you have a test case that shows a bug that was fixed? This would be a breaking change and still unsure of the value. Happy to consider it though!
this PR is based on #24 issue and #27 pull request.
After updating the key storage template from string to nested keys, especially in the
snapshot()
andrestore()
methods there is no clear separation of keys and values of changes if both are objects.snapshot()
returns structure likeThe idea is not to use
getChangeValue()
instead, It will have a structure likeUpdate 04 August 2022
A simpler solution was applied to avoid changing the shape of data and changes could keep their own proptotypes. In
reduce
method of#restore
we should setinitialValue
as: