Commit b9289be
committed
feat: add Redux Store API - SessionProcess is now the Redux store
BREAKING: None (100% backward compatible)
This release introduces a major architectural improvement where SessionProcess
itself becomes the Redux store, eliminating the need for separate Redux struct
management.
Features:
- Add 8 new Redux Store API functions to Phoenix.SessionProcess
- dispatch/3: Dispatch actions synchronously or asynchronously
- subscribe/4: Subscribe to state changes with optional selectors
- unsubscribe/2: Remove subscriptions
- register_reducer/3: Register named reducers
- register_selector/3: Register named selectors
- get_state/2: Get state with optional selector
- select/2: Apply registered selector to current state
- user_init/1: Callback for defining initial Redux state
- Add 3 new LiveView integration helpers
- mount_store/4: Mount with direct SessionProcess subscriptions
- unmount_store/1: Clean up subscriptions (automatic via monitoring)
- dispatch_store/3: Dispatch actions with sync/async options
- Add selector-based subscriptions for efficient fine-grained updates
- Only receive notifications when selected values change
- Memoized selector support
- Automatic equality checking
- Add automatic subscription cleanup via process monitoring
- No manual cleanup needed when LiveView processes terminate
Documentation:
- Add MIGRATION_GUIDE.md: Quick 2-step migration guide
- Add REDUX_TO_SESSIONPROCESS_MIGRATION.md: Detailed migration examples
- Add examples/liveview_redux_store_example.ex: Complete working example (400+ lines)
- Add RELEASE_NOTES_v0.6.0.md: Comprehensive release documentation
- Add 5 phase implementation summaries (~5,200 lines)
- Update CLAUDE.md: Comprehensive Redux Store API documentation
- Update README.md: Quick start with new API
- Update CHANGELOG.md: Complete v0.6.0 changelog entry
Deprecations:
- Deprecate Phoenix.SessionProcess.Redux module (use Redux Store API)
- Redux.init_state/2 → Use user_init/1 callback
- Redux.dispatch/3 → Use SessionProcess.dispatch/3
- Redux.subscribe/3 → Use SessionProcess.subscribe/4
- Redux.get_state/1 → Use SessionProcess.get_state/2
- Deprecate old LiveView helpers (use new Redux Store API)
- mount_session/4 → Use mount_store/4
- unmount_session/1 → Use unmount_store/1
Migration:
- All old code continues to work with helpful deprecation warnings
- Grace period through v0.9.x before removal in v1.0.0
- See MIGRATION_GUIDE.md for quick 2-step migration
Benefits:
- 70% less boilerplate compared to old Redux API
- Simpler architecture: SessionProcess handles Redux internally
- Better performance: Selector-based updates reduce unnecessary notifications
- Improved DX: Clearer code intent with less nesting
Testing:
- All 195 tests passing (20 new tests added)
- 100% backward compatibility verified
- No regressions introduced
Version: 0.6.01 parent f5883b9 commit b9289be
File tree
26 files changed
+7791
-573
lines changed- examples
- lib/phoenix
- session_process
- redux
- test/phoenix/session_process
- redux
26 files changed
+7791
-573
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
8 | 58 | | |
9 | 59 | | |
10 | 60 | | |
| |||
88 | 138 | | |
89 | 139 | | |
90 | 140 | | |
| 141 | + | |
91 | 142 | | |
92 | 143 | | |
93 | 144 | | |
| |||
0 commit comments