You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Valtio uses proxy to abstract away the need to declare the selector functions and state mutation functions. The abstraction is not without cost.
No middlewares
Proxy is a very high-level abstraction, it will make making a middleware correctly very hard.
At the time I write this, there's no middleware support from valito. Such as create a middleware to transform the state before it gets to next middleware (pipeline data). You can only subscribe the changes.
Hard to carry debugging information
If you mutate a state direct on its properties, you will not able to open a window to add extra debugging information to the mutation, for example:
functioncountAll(){state.a++state.b++}
When we call countAll, how can the devtools know what is happening?
With stalo you can do:
functioncountAll(){set((state)=>{state.a++state.b++},meta(countAll,"Count both a and b"))}
As you can see, we can pass extra info to middlewares for better reflection.
Valtio uses proxy to abstract away the need to declare the selector functions and state mutation functions. The abstraction is not without cost.
No middlewares
Proxy is a very high-level abstraction, it will make making a middleware correctly very hard.
At the time I write this, there's no middleware support from valito. Such as create a middleware to transform the state before it gets to next middleware (pipeline data). You can only subscribe the changes.
Hard to carry debugging information
If you mutate a state direct on its properties, you will not able to open a window to add extra debugging information to the mutation, for example:
When we call
countAll
, how can the devtools know what is happening?With stalo you can do:
As you can see, we can pass extra info to middlewares for better reflection.
A lot of corner cases
Use abstraction like proxy has its price.
Like typing support issue: pmndrs/valtio#327
Like accidental proxy replacing: https://valtio.dev/docs/api/basic/useSnapshot
Cache key could refer previous value: pmndrs/valtio#925
The text was updated successfully, but these errors were encountered: