-
I wanted to save the states, and then I saw How to persist states in the documentation, but I have a special case: my states can be huge, and I only want to save the really updated part. For example: const state = proxy(
readStorage() || {
count: 0,
text: 'hello',
},
)
subscribe(state, (changes) => {
// I hope changes will be `{ count: 123 }`, not the whole state `{ count: 123, text: 'hello' }`
setStorage(changes)
})
state.count = 123 |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Dec 14, 2024
Replies: 1 comment
-
Valtio core doesn't track props, so you have to do it on your end.
We have Line 276 in 0870cd1 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lmk123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Valtio core doesn't track props, so you have to do it on your end.
subscribeKey
is provided fromvaltio/utils
, but it works only for a single key.subscribeKeys
is also proposed #887, but nobody has worked on since then.We have
unstable_ops
, but it's considered for library authors or advanced users.valtio/src/vanilla.ts
Line 276 in 0870cd1