Commit a987113
committed
feat(redux): implement named reducer routing with action filtering
Add sophisticated action routing system that directs actions to specific
reducers based on explicit targeting, prefix matching, or automatic inference.
Key features:
- Action normalization in dispatch/2-3 passes routing metadata to reducers
- Three routing strategies: explicit (reducers: [:user]), prefix-based
(reducer_prefix: "user"), and automatic inference from action types
- New Redux.Action struct for consistent action handling across the system
- Reducer identity via @name and @Prefix attributes with compile-time validation
- Support for three combined_reducers formats: Module, {name, Module},
{name, Module, prefix}
- Filter reducers before dispatch to reduce unnecessary processing
Implementation details:
- filter_reducers_for_action/2 determines applicable reducers per action
- filter_by_prefix/2 matches reducers by prefix attribute
- infer_prefix_from_action/1 extracts prefix from "namespace.action" patterns
- Enhanced ActionRateLimiter to handle Action structs
- Fixed debounced action handling to work with combined reducers map structure
Test coverage:
- 9 comprehensive routing tests including explicit targeting, prefix inference,
wildcard routing, and edge cases
- Updated all test reducers to use Action structs for consistency
- Tests for all three combined_reducers formats
- Validation tests for duplicate names and invalid formats
This is Phase 2 of reducer improvements, enabling fine-grained control over
which reducers process which actions, improving performance by avoiding
unnecessary reducer invocations.1 parent 9d14607 commit a987113
File tree
6 files changed
+1588
-58
lines changed- lib/phoenix
- session_process/redux
- test/phoenix/session_process
6 files changed
+1588
-58
lines changed
0 commit comments