Commit 655a2ec
committed
feat(v1.0.0): implement action prefix stripping in reducers
Breaking Change:
- Reducers with @action_prefix now receive action types with the prefix stripped
- Example: With @action_prefix "counter", handle_action receives "increment"
instead of "counter.increment"
- Dispatch calls remain unchanged (still use full prefixed names)
- Catch-all reducers (prefix nil/"") receive unchanged action types
Benefits:
- Cleaner reducer code without prefix repetition
- Reducers focus on local action names
- Better separation of concerns
- Consistent with Redux best practices
Implementation:
- Added strip_action_prefix/2 helper function
- Strips prefix before passing to handle_action/handle_async
- Only affects reducers with non-nil/non-empty @action_prefix
Changes:
- lib/phoenix/session_process.ex: Core prefix stripping logic
- examples/02_redux_reducers.exs: Updated 5 action type patterns
- examples/03_async_actions.exs: Updated 5 action type patterns
- test/phoenix/session_process/reducer_integration_test.exs: Updated 3 patterns
- README.md: Updated 2 documentation patterns
- CLAUDE.md: Updated 5 documentation patterns
- CHANGELOG.md: Added breaking change documentation with migration guide
Testing:
- All 148 tests passing
- Examples 01 and 02 verified working
- Example 03 has unrelated Task reply issue (not from this change)
Migration:
1. Remove prefix from action type patterns in handle_action/handle_async
2. Keep dispatch calls unchanged
3. Only affects reducers with explicit @action_prefix1 parent 98dafc7 commit 655a2ec
File tree
7 files changed
+89
-34
lines changed- examples
- lib/phoenix
- test/phoenix/session_process
7 files changed
+89
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
54 | 87 | | |
55 | 88 | | |
56 | 89 | | |
| |||
72 | 105 | | |
73 | 106 | | |
74 | 107 | | |
75 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
76 | 115 | | |
77 | 116 | | |
78 | 117 | | |
79 | 118 | | |
80 | | - | |
| 119 | + | |
81 | 120 | | |
82 | 121 | | |
83 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | | - | |
| 326 | + | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
| 368 | + | |
369 | 369 | | |
370 | 370 | | |
371 | 371 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1520 | 1520 | | |
1521 | 1521 | | |
1522 | 1522 | | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
1523 | 1540 | | |
1524 | 1541 | | |
1525 | 1542 | | |
1526 | 1543 | | |
1527 | 1544 | | |
1528 | 1545 | | |
1529 | 1546 | | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
1530 | 1551 | | |
1531 | 1552 | | |
1532 | 1553 | | |
| |||
1551 | 1572 | | |
1552 | 1573 | | |
1553 | 1574 | | |
1554 | | - | |
| 1575 | + | |
| 1576 | + | |
1555 | 1577 | | |
1556 | 1578 | | |
1557 | 1579 | | |
| |||
1569 | 1591 | | |
1570 | 1592 | | |
1571 | 1593 | | |
1572 | | - | |
| 1594 | + | |
| 1595 | + | |
1573 | 1596 | | |
1574 | 1597 | | |
1575 | 1598 | | |
| |||
Lines changed: 6 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 23 | | |
28 | 24 | | |
29 | 25 | | |
| |||
56 | 52 | | |
57 | 53 | | |
58 | 54 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 55 | | |
65 | 56 | | |
66 | 57 | | |
| |||
1172 | 1163 | | |
1173 | 1164 | | |
1174 | 1165 | | |
1175 | | - | |
1176 | | - | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
1177 | 1169 | | |
1178 | 1170 | | |
1179 | | - | |
1180 | | - | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1181 | 1174 | | |
1182 | 1175 | | |
1183 | 1176 | | |
| |||
0 commit comments