textual.reactive
This module contains the Reactive
class which implements reactivity.
Reactive ¶
Reactive(
default,
*,
layout=False,
repaint=True,
init=False,
always_update=False,
compute=True,
recompose=False,
bindings=False
)
Bases: Generic[ReactiveType]
Reactive descriptor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
ReactiveType | Callable[[], ReactiveType]
|
A default value or callable that returns a default. |
required |
layout |
bool
|
Perform a layout on change. |
False
|
repaint |
bool
|
Perform a repaint on change. |
True
|
init |
bool
|
Call watchers on initialize (post mount). |
False
|
always_update |
bool
|
Call watchers even when the new value equals the old value. |
False
|
compute |
bool
|
Run compute methods when attribute is changed. |
True
|
recompose |
bool
|
Compose the widget again when the attribute changes. |
False
|
bindings |
bool
|
Refresh bindings when the reactive changes. |
False
|
TooManyComputesError ¶
Bases: ReactiveError
Raised when an attribute has public and private compute methods.
reactive ¶
reactive(
default,
*,
layout=False,
repaint=True,
init=True,
always_update=False,
recompose=False,
bindings=False
)
Bases: Reactive[ReactiveType]
Create a reactive attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
ReactiveType | Callable[[], ReactiveType]
|
A default value or callable that returns a default. |
required |
layout |
bool
|
Perform a layout on change. |
False
|
repaint |
bool
|
Perform a repaint on change. |
True
|
init |
bool
|
Call watchers on initialize (post mount). |
True
|
always_update |
bool
|
Call watchers even when the new value equals the old value. |
False
|
bindings |
bool
|
Refresh bindings when the reactive changes. |
False
|
var ¶
Bases: Reactive[ReactiveType]
Create a reactive attribute (with no auto-refresh).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
ReactiveType | Callable[[], ReactiveType]
|
A default value or callable that returns a default. |
required |
init |
bool
|
Call watchers on initialize (post mount). |
True
|
always_update |
bool
|
Call watchers even when the new value equals the old value. |
False
|
bindings |
bool
|
Refresh bindings when the reactive changes. |
False
|
await_watcher
async
¶
Coroutine to await an awaitable returned from a watcher
invoke_watcher ¶
Invoke a watch function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
watcher_object |
Reactable
|
The object watching for the changes. |
required |
watch_function |
WatchCallbackType
|
A watch function, which may be sync or async. |
required |
old_value |
object
|
The old value of the attribute. |
required |
value |
object
|
The new value of the attribute. |
required |