boolean state in context checkbox #719
-
Great project! I really like the idea of modeling everything as a state machine. While exploring the project, I took a look at the checkbox component and noticed that boolean states are used as flags in the context. In my opinion, it might be beneficial to consider modeling these boolean states as separate states in the state machine. I understand that there may be reasons for using boolean flags, and I'm curious to learn more about the design choices behind it. To me, having boolean flags in the context suggests that these states could be modeled explicitly in the state machine since they are finite. What are your thoughts on this? https://github.com/chakra-ui/zag/blob/main/packages/machines/checkbox/src/checkbox.machine.ts |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @oppianmatt, You're right that the checkbox states should be modeled as separate states. We did that initially. This started to fall apart in scenarios where users might want to explicitly control the machine's state from their framework via some local state. Syncing those two pieces of state was a bit challenging (even though I think it can be done) Considering the current solution is temporary, we might still consider moving from context to explicit state in the future. |
Beta Was this translation helpful? Give feedback.
Hi @oppianmatt,
You're right that the checkbox states should be modeled as separate states. We did that initially.
This started to fall apart in scenarios where users might want to explicitly control the machine's state from their framework via some local state. Syncing those two pieces of state was a bit challenging (even though I think it can be done)
Considering the current solution is temporary, we might still consider moving from context to explicit state in the future.