Commit 8894a1e
committed
feat: implement PubSub-based LiveView integration and consolidate process macros
BREAKING CHANGE: :process_link macro is deprecated in favor of :process
This commit introduces a modern PubSub-based LiveView integration and consolidates
the session process macros for a simpler, more maintainable API.
Features:
- Add PubSub-based LiveView integration with mount/unmount lifecycle
- Consolidate :process and :process_link macros (all processes now linked by default)
- Add broadcast_state_change/1-2 helper for session state broadcasts
- Add Phoenix.SessionProcess.LiveView helper module with mount_session/unmount_session
- Support distributed LiveView subscriptions across nodes
- Remove manual LiveView tracking from process state
Breaking Changes:
- :process_link macro deprecated (use :process instead)
- Removed handle_cast({:monitor, pid}) from :process macro
- Removed handle_info({:DOWN, ...}) for LiveView monitoring
- Removed :session_expired message on process termination
- LiveView integration now requires PubSub configuration
Migration:
- Change "use Phoenix.SessionProcess, :process_link" to ":process"
- Use Phoenix.SessionProcess.LiveView.mount_session/3 in LiveView mount
- Call broadcast_state_change(state) in session processes to notify LiveViews
- Add pubsub configuration: config :phoenix_session_process, pubsub: MyApp.PubSub
Documentation:
- Update CLAUDE.md with new architecture and LiveView patterns
- Update README.md with PubSub integration examples
- Add comprehensive example file: examples/liveview_integration_example.ex
- Update MIGRATION_GUIDE.md with Redux usage fixes
Tests:
- Add 49 new tests for PubSub LiveView integration
- Test coverage: mount/unmount, broadcast, error handling, distributed scenarios
- All 176 tests passing
- Test files: live_view_test.exs, pubsub_broadcast_test.exs, live_view_integration_test.exs1 parent 7e7a8da commit 8894a1e
File tree
12 files changed
+2189
-81
lines changed- examples
- lib/phoenix
- session_process
- test
- phoenix
- session_process
- support
12 files changed
+2189
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | | - | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
115 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
116 | 129 | | |
117 | 130 | | |
118 | 131 | | |
119 | 132 | | |
120 | | - | |
| 133 | + | |
121 | 134 | | |
122 | 135 | | |
123 | 136 | | |
| |||
139 | 152 | | |
140 | 153 | | |
141 | 154 | | |
142 | | - | |
143 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
144 | 161 | | |
145 | 162 | | |
146 | 163 | | |
| |||
152 | 169 | | |
153 | 170 | | |
154 | 171 | | |
155 | | - | |
| 172 | + | |
| 173 | + | |
156 | 174 | | |
157 | 175 | | |
158 | 176 | | |
159 | 177 | | |
160 | 178 | | |
161 | 179 | | |
162 | 180 | | |
| 181 | + | |
163 | 182 | | |
164 | 183 | | |
165 | 184 | | |
166 | 185 | | |
167 | 186 | | |
168 | | - | |
| 187 | + | |
169 | 188 | | |
170 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
171 | 246 | | |
172 | 247 | | |
173 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
183 | | - | |
| 183 | + | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
146 | 149 | | |
147 | 150 | | |
148 | | - | |
149 | | - | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
153 | | - | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
157 | | - | |
158 | | - | |
| 160 | + | |
| 161 | + | |
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
163 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
164 | 177 | | |
165 | 178 | | |
166 | 179 | | |
167 | 180 | | |
168 | | - | |
| 181 | + | |
169 | 182 | | |
170 | 183 | | |
171 | | - | |
172 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
173 | 193 | | |
174 | | - | |
175 | | - | |
176 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
177 | 208 | | |
178 | 209 | | |
179 | | - | |
180 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
181 | 214 | | |
182 | 215 | | |
183 | 216 | | |
184 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
185 | 228 | | |
186 | 229 | | |
187 | 230 | | |
| |||
0 commit comments