-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add MobX-inspired reactive state management prototype #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Introduce a new `src/state/` module with reactive primitives: - Signal(T): Observable state with change notifications - Computed(T): Derived values with automatic dependency tracking - Effect: Side effects that re-run when dependencies change - ObservableArray/ObservableMap: Reactive collections - Transaction: Batched updates for atomic state changes Add comprehensive refactoring plan in docs/state-management-refactor.md with status quo analysis, migration phases, and acceptance criteria. This is a foundational prototype - no existing code is modified to use the new system yet. Migration will proceed incrementally per the plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0c77f9953
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a foundational reactive state management system inspired by MobX, adding new primitives (Signal, Computed, Effect, ObservableArray, ObservableMap, Transaction) in the src/state/ module. It includes comprehensive documentation of the migration plan without modifying existing application code.
Changes:
- Implemented core reactive primitives with automatic dependency tracking
- Added comprehensive unit tests for all new state management components
- Documented migration strategy and integration plan in
docs/state-management-refactor.md
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/state/tracker.zig | Implements dependency tracking context with batching support for reactive updates |
| src/state/signal.zig | Core observable primitive with subscriber notifications and equality-based change detection |
| src/state/computed.zig | Derived reactive values with lazy evaluation and automatic dependency tracking |
| src/state/effect.zig | Side effects that automatically re-run when tracked dependencies change |
| src/state/store.zig | Higher-level constructs including reactive collections and transaction batching |
| src/state/mod.zig | Public module exports and API documentation with usage examples |
| docs/state-management-refactor.md | Comprehensive migration plan detailing phased refactoring approach |
| docs/architecture.md | Updated architecture documentation to include new reactive state module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Restore prior tracking context after recompute to support nested computed evaluations - Add dependency subscription so computeds/effects automatically react to signal changes via a global registry - Fix ArrayList initializations to use proper allocator-based init - Expose generateNodeId() and use it directly to avoid memory leaks from temporary Signal creation - Make node ID generation thread-safe with std.atomic.Value - Make tracking context thread-local for multi-threaded safety
Introduce a new
src/state/module with reactive primitives:Add comprehensive refactoring plan in docs/state-management-refactor.md
with status quo analysis, migration phases, and acceptance criteria.
This is a foundational prototype - no existing code is modified to use
the new system yet. Migration will proceed incrementally per the plan.