How udecode/zustand-x works
Main Components
a) Core Components:
• Store Factory System
• Selector System
• Action System
• Middleware System
b) Integration Components:
• React Components Layer
• Zustand Core Integration
• Global Store Management
[Application Layer]
• ↑↓
[ZustandX Layer]
• ↑↓
[Zustand Core Layer]
Specific Elements
a) Store Creation Flow:
• createStore factory function
• How initial state flows through the system
• Middleware integration points (immer, devtools, persist)
b) State Management Components:
• Selector System
• Hook Selectors
• Tracked Selectors (react-tracked integration)
• Getter Selectors
• Action System
• State Setters
• Extended Actions
c) Global Store Architecture:
• Root Store Combination
• Global Selectors
• Global Actions
Key Relationships to Highlight
• How the store factory creates individual stores
• Relationship between stores and their selectors/actions
• Demonstrate middleware pipeline
• Connection between global store and individual stores
Implementation Details
[Component Name]
Key Functions
Input/Output
Dependencies
Flow Patterns
• Data flow direction
• Component dependencies
• State updates
• Selector subscription patterns
Technical Details
• Store creation pipeline
• Middleware integration points
• Selector generation system
• Action extension system
• Global store mapping system
Remember to include notes about:
• TypeScript integration
• React integration points
• Middleware configuration
• Global store patterns
This will provide a comprehensive view of how ZustandX enhances Zustand with additional features while maintaining its core benefits of being small, fast, and scalable.