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