Hello,
I am using on-change to watch changes in the state of my application.
Until now, I was using the default configuration. With this, when I listen to a change in my list, if I add a new element in my list, the path I get in the onChange method if the array itself.
For example:
this.proxy = onChange(
this.state,
(path, value, oldValue, _applyData) => {
/* Do something */
},
{
ignoreUnderscores: true,
ignoreSymbols: true,
});
And when I do this.state.selectedFeatures.push(...features)
, then the path in the onChange method is selectedFeatures
.
Now, I add some problems with some functions like forEach()
, which were not triggering all the events, but only one event at the end of the loop. So I've tried to activated the details:true
options, as documented. This worked well, except that now the path has changed when I add elements in my list.
For example, now I have:
this.proxy = onChange(
this.state,
(path, value, oldValue, _applyData) => {
/* Do something */
},
{
ignoreUnderscores: true,
ignoreSymbols: true,
details: true
});
And when I do this.state.selectedFeatures.push(...features)
, then the path in the onChange method is now selectedFeatures.0
.
I don't really understand the philosophy here. Is it intentional? Is it a bug?
(I could perhaps try to sove it by myself in a Pull-Request, but I would be happy to discuss this before.)
Thanks.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too