You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- fix#203
- Some miscellaneous refactoring on the websocket `consumer` and `UserDataModel`, just because I happened to notice some cleanup potential while making this PR.
Copy file name to clipboardExpand all lines: docs/src/reference/hooks.md
+30
Original file line number
Diff line number
Diff line change
@@ -492,6 +492,8 @@ Shortcut that returns the browser's current `#!python Location`.
492
492
| --- | --- |
493
493
| `#!python Location` | An object containing the current URL's `#!python pathname` and `#!python search` query. |
494
494
495
+
---
496
+
495
497
### Use Origin
496
498
497
499
Shortcut that returns the WebSocket or HTTP connection's `#!python origin`.
@@ -518,6 +520,34 @@ You can expect this hook to provide strings such as `http://example.com`.
518
520
519
521
---
520
522
523
+
### Use Root ID
524
+
525
+
Shortcut that returns the root component's `#!python id` from the WebSocket or HTTP connection.
526
+
527
+
The root ID is currently a randomly generated `#!python uuid4` (unique across all root component).
528
+
529
+
This is useful when used in combination with [`#!python use_channel_layer`](#use-channel-layer) to send messages to a specific component instance, and/or retain a backlog of messages in case that component is disconnected via `#!python use_channel_layer( ... , group_discard=False)`.
530
+
531
+
=== "components.py"
532
+
533
+
```python
534
+
{% include "../../examples/python/use-root-id.py" %}
535
+
```
536
+
537
+
??? example "See Interface"
538
+
539
+
<font size="4">**Parameters**</font>
540
+
541
+
`#!python None`
542
+
543
+
<font size="4">**Returns**</font>
544
+
545
+
| Type | Description |
546
+
| --- | --- |
547
+
| `#!python str` | A string containing the root component's `#!python id`. |
548
+
549
+
---
550
+
521
551
### Use User
522
552
523
553
Shortcut that returns the WebSocket or HTTP connection's `#!python User`.
0 commit comments