News for hackers. Stuff that matters.
Re:CCState is a semantic, strict, and flexible state managem... by acmerfight on Thursday December 19, 2024 @05:14AM (#42460108)
CCState is a semantic, strict, and flexible state management library suitable for medium to large single-page applications with complex state management needs.

The name of CCState comes from three basic data types: computed, command, and state.

Re:CCState is a semantic, strict, and flexible state managem... by kaoD on Thursday December 19, 2024 @05:22PM (#42466347)
Interesting! Will give it a try.

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.

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.