Replies: 3 comments 10 replies
-
|
Hi. Thank you for your great work |
Beta Was this translation helpful? Give feedback.
-
|
Hey, thanks for the great work on this library! I noticed that you mentioned planning to enable I’m currently building a higher-level state management solution on top of Valtio, and I’m trying to understand how this change might affect my implementation going forward. Right now, I’m working on a “selectors” concept for the store. The idea is that selector subscribers are only notified when the specific properties they access actually change. This is implemented using Here’s a simple example of a selector: filteredItems(key) {
return this.state.items[key] + this.state.counter
}And subscribing to it: store.filteredItems.subscribe("key_1", value => {
// ...
})Under the hood, the selector implementation looks roughly like this: subscribeSelector: (callback) => {
const proxyObj = proxy({ value: undefined });
const effectUnsubscribe = effect(() => {
proxyObj.value = selectorFn(...args);
});
const subscribeUnsubscribe = subscribe(
proxyObj,
() => {
callback(snapshot(proxyObj).value);
},
true,
);
return () => {
effectUnsubscribe();
subscribeUnsubscribe();
};
},When To solve this, I switched to subscribing asynchronously so that updates happen in a separate event loop, which resolved the issue. Given that |
Beta Was this translation helpful? Give feedback.
-
|
My turn for suggestions : About notifyInSyncCurrently in I'm using valtio in react and server side, and i love the auto-batching feature of As far as i understand, without valtio-reactive i couldn't have the same behavior ? Could we consider changing the default but keep the possibility ? Add branded typesCurrently it's hard at development time to guess whether an object is a proxy or not. I vote for a Type branding for You can grab more at https://github.com/sindresorhus/type-fest/blob/main/source/tagged.d.ts
I'm already wrapping valtio stuff like this in my code, and this add more security layer. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Just some notes for myself. Nothing is determined.
use(store)https://react.dev/blog/2025/04/23/react-labs-view-transitions-activity-and-more#concurrent-stores and redesign our APIproxy-compareapplyChanges()like https://github.com/jotaijs/jotai-valtionotifyInSync=trueand introducesbatch()like https://github.com/valtiojs/valtio-reactivewatchwith deprecating it in v2unstable_replaceInternalFunctionwith more robust/pluggable solution.Beta Was this translation helpful? Give feedback.
All reactions