Skip to content

Reactive

Reactive

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. Defaults to False.

False
repaint bool

Perform a repaint on change. Defaults to True.

True
init bool

Call watchers on initialize (post mount). Defaults to False.

False
always_update bool

Call watchers even when the new value equals the old value. Defaults to False.

False

init(default, *, layout=False, repaint=True, always_update=False) classmethod

A reactive variable that calls watchers and compute on initialize (post mount).

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. Defaults to False.

False
repaint bool

Perform a repaint on change. Defaults to True.

True
always_update bool

Call watchers even when the new value equals the old value. Defaults to False.

False

Returns:

Name Type Description
Reactive Reactive

A Reactive instance which calls watchers or initialize.

var(default) classmethod

A reactive variable that doesn't update or layout.

Parameters:

Name Type Description Default
default ReactiveType | Callable[[], ReactiveType]

A default value or callable that returns a default.

required

Returns:

Name Type Description
Reactive Reactive

A Reactive descriptor.

reactive

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. Defaults to False.

False
repaint bool

Perform a repaint on change. Defaults to True.

True
init bool

Call watchers on initialize (post mount). Defaults to True.

True
always_update bool

Call watchers even when the new value equals the old value. Defaults to False.

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). Defaults to True.

True

watch(obj, attribute_name, callback, init=True)

Watch a reactive variable on an object.

Parameters:

Name Type Description Default
obj Reactable

The parent object.

required
attribute_name str

The attribute to watch.

required
callback Callable[[Any], object]

A callable to call when the attribute changes.

required
init bool

True to call watcher initialization. Defaults to True.

True