State Management
Smithers uses two complementary state systems:- Solid.js Signals - Reactive in-memory state that drives re-renders
- Database Persistence - PGlite storage that survives restarts
Solid.js Signals
Signals are the reactive primitive that powers the Ralph Wiggum Loop:Signal Basics
Signals in JSX
Signals automatically trigger re-renders when read in JSX:Solid.js Stores
For complex nested state, use stores:Store Updates
Database Persistence
Signals are in-memory only. For persistence across restarts, use the database:Database State API
Combining Signals and Database
A common pattern is to initialize signals from the database:Snapshots and Restore
Save and restore complete state snapshots:Effects and Derived State
UsecreateEffect for side effects when state changes:
Best Practices
Always read signals as functions
Always read signals as functions
Signals must be called to track reactivity:
Persist critical state to database
Persist critical state to database
Anything that should survive a restart needs database persistence:
Use stores for complex state
Use stores for complex state
Stores handle nested updates better than multiple signals: