pmndrs / valtio

💊 Valtio makes proxy-state simple for React and Vanilla
http://valtio.pmnd.rs
MIT License
8.7k stars 244 forks source link

Vanilla `subscribe` does not trigger when a computed getter is updated #743

Closed sharathprabhal closed 1 year ago

sharathprabhal commented 1 year ago

Discussed in https://github.com/pmndrs/valtio/discussions/742

Originally posted by **sharathprabhal** June 29, 2023 I use Valtio as a store for in a project that uses both React and vanilla. I have a keyed object of items in a store. Based on user action, I set a "derived" currentObject and use a getter to select "current object" and perform operations on it. When the "current object" is updated, `useSnapshot` triggers but subscribe does not. See repro code at https://codesandbox.io/s/valtio-subscribe-57p4st Please let me know if this is a bug or if there is a alternate/better way to do this. Thanks!
dai-shi commented 1 year ago

Please keep discussing in #742.

sharathprabhal commented 1 year ago

Thanks @dai-shi , any guidance is greatly appreciated!