from reactivity.primitives import *¶
Subscribable
¶
Source code in reactivity/primitives.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
subscribers
instance-attribute
¶
subscribers = set[BaseComputation]()
context
instance-attribute
¶
context = context or default_context
__init__
¶
__init__(*, context: Context | None = None)
Source code in reactivity/primitives.py
27 28 29 30 |
|
track
¶
track()
Source code in reactivity/primitives.py
32 33 34 35 36 37 38 39 40 41 |
|
notify
¶
notify()
Source code in reactivity/primitives.py
43 44 45 46 47 48 49 50 |
|
BaseComputation
¶
Source code in reactivity/primitives.py
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 |
|
dependencies
instance-attribute
¶
dependencies = WeakSet[Subscribable]()
context
instance-attribute
¶
context = context or default_context
reactivity_loss_strategy
class-attribute
instance-attribute
¶
reactivity_loss_strategy: Literal[
"ignore", "warn", "restore"
] = "warn"
A computation without dependencies usually indicates a code mistake.
By default, a warning is issued when a computation completes without collecting any dependencies. This often happens when signal access is behind non-reactive conditions or caching. You can set this to "restore" to automatically preserve previous dependencies as a temporary workaround. The correct practice is to replace those conditions with reactive ones (e.g. Signal) or use Derived for caching.
Consider "ignore" only when extending this library and manually managing dependencies. Use with caution.
__init__
¶
__init__(*, context: Context | None = None)
Source code in reactivity/primitives.py
54 55 56 57 |
|
dispose
¶
dispose()
Source code in reactivity/primitives.py
59 60 61 62 |
|
_enter
¶
_enter()
Source code in reactivity/primitives.py
64 65 |
|
__enter__
¶
__enter__()
Source code in reactivity/primitives.py
67 68 |
|
__exit__
¶
__exit__(*_)
Source code in reactivity/primitives.py
70 71 |
|
__call__
¶
__call__() -> T
Source code in reactivity/primitives.py
75 76 |
|
Signal
¶
Bases: Subscribable
flowchart TD
reactivity.primitives.Signal[Signal]
reactivity.primitives.Subscribable[Subscribable]
reactivity.primitives.Subscribable --> reactivity.primitives.Signal
click reactivity.primitives.Signal href "" "reactivity.primitives.Signal"
click reactivity.primitives.Subscribable href "" "reactivity.primitives.Subscribable"
Source code in reactivity/primitives.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
_value
instance-attribute
¶
_value: T = initial_value
_check_equality
instance-attribute
¶
_check_equality = check_equality
__init__
¶
__init__(
initial_value: T = None,
check_equality=True,
*,
context: Context | None = None,
)
Source code in reactivity/primitives.py
92 93 94 95 |
|
get
¶
get(track=True)
Source code in reactivity/primitives.py
97 98 99 100 |
|
set
¶
set(value: T)
Source code in reactivity/primitives.py
102 103 104 105 106 107 |
|
update
¶
update(updater: Callable[[T], T])
Source code in reactivity/primitives.py
109 110 |
|
DescriptorMixin
¶
Source code in reactivity/primitives.py
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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
SLOT_KEY
class-attribute
instance-attribute
¶
SLOT_KEY = '_reactive_descriptors_'
__set_name__
¶
__set_name__(owner: type, name: str)
Source code in reactivity/primitives.py
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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
_new
¶
_new(instance) -> T
Source code in reactivity/primitives.py
165 |
|
find
¶
find(instance) -> T
Source code in reactivity/primitives.py
167 168 169 170 171 172 173 174 175 176 177 178 |
|
State
¶
Bases: Signal[T], DescriptorMixin[Signal[T]]
flowchart TD
reactivity.primitives.State[State]
reactivity.primitives.Signal[Signal]
reactivity.primitives.Subscribable[Subscribable]
reactivity.primitives.DescriptorMixin[DescriptorMixin]
reactivity.primitives.Signal --> reactivity.primitives.State
reactivity.primitives.Subscribable --> reactivity.primitives.Signal
reactivity.primitives.DescriptorMixin --> reactivity.primitives.State
click reactivity.primitives.State href "" "reactivity.primitives.State"
click reactivity.primitives.Signal href "" "reactivity.primitives.Signal"
click reactivity.primitives.Subscribable href "" "reactivity.primitives.Subscribable"
click reactivity.primitives.DescriptorMixin href "" "reactivity.primitives.DescriptorMixin"
Source code in reactivity/primitives.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
_value
instance-attribute
¶
_value = initial_value
_check_equality
instance-attribute
¶
_check_equality = check_equality
__init__
¶
__init__(
initial_value: T = None,
check_equality=True,
*,
context: Context | None = None,
)
Source code in reactivity/primitives.py
182 183 184 185 |
|
__get__
¶
__get__(instance: None, owner: type) -> Self
__get__(instance: Any, owner: type) -> T
Source code in reactivity/primitives.py
192 193 194 195 |
|
__set__
¶
__set__(instance, value: T)
Source code in reactivity/primitives.py
197 198 |
|
_new
¶
_new(instance)
Source code in reactivity/primitives.py
200 201 |
|
Effect
¶
Bases: BaseComputation[T]
flowchart TD
reactivity.primitives.Effect[Effect]
reactivity.primitives.BaseComputation[BaseComputation]
reactivity.primitives.BaseComputation --> reactivity.primitives.Effect
click reactivity.primitives.Effect href "" "reactivity.primitives.Effect"
click reactivity.primitives.BaseComputation href "" "reactivity.primitives.BaseComputation"
Source code in reactivity/primitives.py
204 205 206 207 208 209 210 211 212 213 214 215 |
|
_fn
instance-attribute
¶
_fn = fn
__init__
¶
__init__(
fn: Callable[[], T],
call_immediately=True,
*,
context: Context | None = None,
)
Source code in reactivity/primitives.py
205 206 207 208 209 210 211 |
|
trigger
¶
trigger()
Source code in reactivity/primitives.py
213 214 215 |
|
Batch
¶
Source code in reactivity/primitives.py
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 246 247 |
|
callbacks
instance-attribute
¶
callbacks = set[BaseComputation]()
force_flush
instance-attribute
¶
force_flush = force_flush
context
instance-attribute
¶
context = context or default_context
__init__
¶
__init__(
force_flush=True, *, context: Context | None = None
)
Source code in reactivity/primitives.py
219 220 221 222 |
|
flush
¶
flush()
Source code in reactivity/primitives.py
224 225 226 227 228 229 230 231 232 233 |
|
__enter__
¶
__enter__()
Source code in reactivity/primitives.py
235 236 |
|
__exit__
¶
__exit__(*_)
Source code in reactivity/primitives.py
238 239 240 241 242 243 244 245 246 247 |
|
BaseDerived
¶
Bases: Subscribable, BaseComputation[T]
flowchart TD
reactivity.primitives.BaseDerived[BaseDerived]
reactivity.primitives.Subscribable[Subscribable]
reactivity.primitives.BaseComputation[BaseComputation]
reactivity.primitives.Subscribable --> reactivity.primitives.BaseDerived
reactivity.primitives.BaseComputation --> reactivity.primitives.BaseDerived
click reactivity.primitives.BaseDerived href "" "reactivity.primitives.BaseDerived"
click reactivity.primitives.Subscribable href "" "reactivity.primitives.Subscribable"
click reactivity.primitives.BaseComputation href "" "reactivity.primitives.BaseComputation"
Source code in reactivity/primitives.py
250 251 252 253 254 255 256 257 258 259 |
|
dirty
instance-attribute
¶
dirty = True
__init__
¶
__init__(*, context: Context | None = None)
Source code in reactivity/primitives.py
251 252 253 |
|
_sync_dirty_deps
¶
_sync_dirty_deps() -> Any
Source code in reactivity/primitives.py
255 256 257 258 259 |
|
Derived
¶
Bases: BaseDerived[T]
flowchart TD
reactivity.primitives.Derived[Derived]
reactivity.primitives.BaseDerived[BaseDerived]
reactivity.primitives.Subscribable[Subscribable]
reactivity.primitives.BaseComputation[BaseComputation]
reactivity.primitives.BaseDerived --> reactivity.primitives.Derived
reactivity.primitives.Subscribable --> reactivity.primitives.BaseDerived
reactivity.primitives.BaseComputation --> reactivity.primitives.BaseDerived
click reactivity.primitives.Derived href "" "reactivity.primitives.Derived"
click reactivity.primitives.BaseDerived href "" "reactivity.primitives.BaseDerived"
click reactivity.primitives.Subscribable href "" "reactivity.primitives.Subscribable"
click reactivity.primitives.BaseComputation href "" "reactivity.primitives.BaseComputation"
Source code in reactivity/primitives.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
UNSET
class-attribute
instance-attribute
¶
UNSET: T = object()
fn
instance-attribute
¶
fn = fn
_check_equality
instance-attribute
¶
_check_equality = check_equality
_value
instance-attribute
¶
_value = UNSET
__init__
¶
__init__(
fn: Callable[[], T],
check_equality=True,
*,
context: Context | None = None,
)
Source code in reactivity/primitives.py
265 266 267 268 269 |
|
recompute
¶
recompute()
Source code in reactivity/primitives.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
__call__
¶
__call__()
Source code in reactivity/primitives.py
286 287 288 289 290 291 292 |
|
trigger
¶
trigger()
Source code in reactivity/primitives.py
294 295 296 297 |
|
invalidate
¶
invalidate()
Source code in reactivity/primitives.py
299 300 |
|
_equal
¶
_equal(a, b)
Source code in reactivity/primitives.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
_pulled
¶
_pulled(sub: Subscribable)
Source code in reactivity/primitives.py
303 304 305 306 307 308 309 310 311 312 313 |
|