omnipy.util.publisher
Observable Pydantic models for propagating attribute change notifications.
This module provides publisher models that notify subscribers when their public attributes change, including nested publisher attributes used in runtime and configuration state.
| CLASS | DESCRIPTION |
|---|---|
DataPublisher |
Pydantic model that publishes updates to subscribers. |
RuntimeEntryPublisher |
Data publisher that resets runtime subscriptions on value replacement. |
DataPublisher
flowchart BT
omnipy.util.publisher.DataPublisher[DataPublisher]
omnipy.util.pydantic.BaseModel --> omnipy.util.publisher.DataPublisher
click omnipy.util.publisher.DataPublisher href "" "omnipy.util.publisher.DataPublisher"
Pydantic model that publishes updates to subscribers.
Subscribers can watch a single public attribute or the whole model. Nested
DataPublisher attributes propagate their changes to parent subscribers.
- Reference Code reference omnipy
| CLASS | DESCRIPTION |
|---|---|
Config |
Pydantic settings for |
| METHOD | DESCRIPTION |
|---|---|
deepcopy |
Create a deep copy with subscriptions reset on the copied object. |
subscribe |
Subscribe to updates for the full publisher object. |
subscribe_attr |
Subscribe to updates for one public attribute. |
unsubscribe_all |
Remove all subscriptions from this publisher and nested publishers. |
Source code in src/omnipy/util/publisher.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
Config
Pydantic settings for DataPublisher models.
| ATTRIBUTE | DESCRIPTION |
|---|---|
arbitrary_types_allowed |
|
validate_assignment |
|
Source code in src/omnipy/util/publisher.py
deepcopy
Create a deep copy with subscriptions reset on the copied object.
| RETURNS | DESCRIPTION |
|---|---|
Self
|
A deep-copied publisher with empty subscription registries. |
Source code in src/omnipy/util/publisher.py
subscribe
Subscribe to updates for the full publisher object.
The callback receives self whenever any public attribute changes.
| PARAMETER | DESCRIPTION |
|---|---|
callback_fun
|
Callback receiving the publisher instance.
TYPE:
|
do_callback
|
When
TYPE:
|
Source code in src/omnipy/util/publisher.py
subscribe_attr
Subscribe to updates for one public attribute.
The callback is invoked immediately with the current attribute value.
| PARAMETER | DESCRIPTION |
|---|---|
attr_name
|
Public attribute name to observe.
TYPE:
|
callback_fun
|
Callback receiving the current/new attribute value.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
AttributeError
|
If |
Source code in src/omnipy/util/publisher.py
unsubscribe_all
Remove all subscriptions from this publisher and nested publishers.
Source code in src/omnipy/util/publisher.py
RuntimeEntryPublisher
Bases: DataPublisher
flowchart BT
omnipy.util.publisher.RuntimeEntryPublisher[RuntimeEntryPublisher]
omnipy.util.publisher.DataPublisher[DataPublisher]
omnipy.util.publisher.DataPublisher --> omnipy.util.publisher.RuntimeEntryPublisher
omnipy.util.pydantic.BaseModel --> omnipy.util.publisher.DataPublisher
click omnipy.util.publisher.RuntimeEntryPublisher href "" "omnipy.util.publisher.RuntimeEntryPublisher"
click omnipy.util.publisher.DataPublisher href "" "omnipy.util.publisher.DataPublisher"
Data publisher that resets runtime subscriptions on value replacement.
When a public attribute is rebound to a different object and a runtime backend is attached, the runtime subscription graph is rebuilt.