Re:CCState is a semantic, strict, and flexible state managem...
by aidos on Thursday December 19, 2024 @06:01PM
(#42466635)
Mobx has similar patterns with the computeds. They allow you to have a little more control over their lifecycle. The general rule is that they’re kept alive until they’re no longer observed but you can pass a flag to keep them around even when they’re not needed.
I like how you properly used useSyncExternalStore and AbortController for signaling. Always a good sign seeing good use of APIs.
(EDIT) Quick question: will computed values be lazy and cached? I'm worried changing an atom could trigger a huge cascade of changes (most of which will not even be observed) but also that expensive values could get thrown away once not observed anymore (even if briefly, think e.g. a quick remount) but also that it might get cached for too long (or never discarded).
How is all this handled internally?
(EDIT2) I'm reading through the README and the rationale/comparison with Jotai looks very solid. I'm really impressed. Kudos.