Commit 573141b
Add doc examples using attach_hook for code organization instead of LiveComponents (#3685)
* Update attach_hook/4 with extract handle_event example
* Add small header for doc linking
* Clarify the code-organization sections of the Welcome guide
Add small hierarchy headers to the "Compartmentalize state,
markup, and events" section
Use the guidance in "Functional components or live components?"
at the top of `Phoenix.LiveComponent` to avoid using LiveComponents
only for organization
Provide longer example with a few different alternatives of
what *can* be used for organizing events
* Remove suggested option to delegate events manually
As pointed out, sticking with attach_hook keeps ownership of
the event in the new component
* Remove Helpers and use more-standard {:ok, socket} style
* Add forgotten line break
* Remove 2nd attach_hook example and link directly to the first
* Update lib/phoenix_live_view.ex
* Update guides/introduction/welcome.md
* Update guides/introduction/welcome.md
* Update guides/introduction/welcome.md
* Update guides/introduction/welcome.md
* Update guides/introduction/welcome.md
* Update guides/introduction/welcome.md
* Update guides/introduction/welcome.md
* Reverse locations of long-code-example & link-to-that-example
Now the "using attach_hook/4 to extract handle_events" example
code is actually kept in the doc FOR attach_hook
This keeps the welcome.md page similar to it's original size
* Rename "Organizing code" section -> "Sharing event handling logic"
* Continue minimizing changes to welcome.md
- Merge the "attach_hook/4 to organize event handling" section into
the "Function components" one above it
- Return to the previous bullet-point based summary, adding only a single
line to emphasize that function components can work alone for markup, but
also organize event handling when paired with attach_hook/4
* Apply suggestions from code review
* Apply suggestions from code review
---------
Co-authored-by: Gary Rennie <[email protected]>
Co-authored-by: Steffen Deusch <[email protected]>
Co-authored-by: José Valim <[email protected]>1 parent ea2c6f0 commit 573141b
2 files changed
+90
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
| |||
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
251 | 260 | | |
252 | 261 | | |
253 | 262 | | |
| |||
261 | 270 | | |
262 | 271 | | |
263 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
264 | 278 | | |
265 | 279 | | |
266 | 280 | | |
| |||
277 | 291 | | |
278 | 292 | | |
279 | 293 | | |
280 | | - | |
281 | | - | |
282 | | - | |
| 294 | + | |
| 295 | + | |
283 | 296 | | |
284 | 297 | | |
285 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1508 | 1508 | | |
1509 | 1509 | | |
1510 | 1510 | | |
1511 | | - | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
1512 | 1582 | | |
1513 | 1583 | | |
1514 | 1584 | | |
| |||
0 commit comments