proxyMap subscription ops don't include keys #977
Replies: 4 comments 9 replies
-
Oh, shoot, wait, this is working as intended? #514 |
Beta Was this translation helpful? Give feedback.
-
Just to confirm, is this a new behavior changed in v2.1.0? Or, is it the same with v2.0.0? |
Beta Was this translation helpful? Give feedback.
-
This is actually a side effect of how we get reactive behavior working with proxyMap, I believe. The main reason we have to create an emulation for Maps is that they store their data in internal slots and changes to the data are not visible outside of the map, which is necessary for valtio to be reactive. To overcome this, we store the data in a data property that valtio can view. I'm not sure if this is something that can be fixed easily due to the limitation of the design. I do have a few ideas but it would require changes to both subscribe and proxyMap. |
Beta Was this translation helpful? Give feedback.
-
Propositional fix: |
Beta Was this translation helpful? Give feedback.
-
Bug Description
Operations passed to the subscribe handler for proxyMap don't include the key in the path, but instead include internal implementation details.
Setting a value shows up like this:
While I would expect it to show up like:
Am I using this wrong? Or is this working as intended? (I also snuck in
undefined
vsnull
in that example, but that might be more controversial)Reproduction Link
https://codepen.io/coracuity/pen/rNXwMMz
Beta Was this translation helpful? Give feedback.
All reactions