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