How oryoffe/jstates-react works
Main Components
a) Core Components:
• State Store Manager
• React Integration Layer
• Subscription System
b) Public API Components:
• createState() function
• useSubscribe() hook
• subscribe() HOC (Higher-Order Component)
┌─ Application Layer ─────────────────────┐
• React Components │
• User Code │
• ┬─┘
• ↕️ │
┌─ Integration Layer ──────────────────┴─┐
• ┌─ React Bindings ─────────────────┐ │
• useSubscribe Hook │ │
• subscribe HOC │ │
• ┬─┘ │
• ↕️ │ │
• ┌─ State Management ─────────────┴─┐ │
• createState │ │
• setState │ │
• State Store │ │
• ┬─┘ │
• ┬─┘ │
• ↕️ │ │
┌─ Core State Layer ──────────────┴──────┘
• State Objects │
• Subscription Management │
• State Updates │
• ┬─┘
Important Elements to Highlight
a) Data Flow:
• Unidirectional data flow from state updates to subscribed components
• Subscription registration flow
• Demonstrate state modification paths
b) Integration Points:
• How useSubscribe hook connects to components
• HOC wrapper functionality
• State creation and management flow
Additional Details
A side panel showing:
• State Instance Structure
• Component Integration Examples
• Subscription Flow
Technical Specifications to Note
• TypeScript support (based on .tsx files)
• React compatibility
• Build system (Rollup + Babel)
Implementation Notes
• Simplicity of the state management system
• Direct connection between state and React components
• Minimal middleware or complexity
• Both Hook and HOC patterns for flexibility