slash.reactive
- class slash.reactive.Computed(fn)
Bases:
Generic[T]Reactive value computed from other reactive values.
- Parameters:
fn (Callable[[], T]) – Function that computes the value from other reactive values.
- get()
Return the current value.
- Return type:
T
- class slash.reactive.Effect(fn)
Bases:
objectReactive effect that runs automatically when the reactive values that it depends are updated.
- Parameters:
fn (Callable[[], Any]) – Function that executes the effect from reactive values.
- class slash.reactive.Signal(value)
Bases:
Generic[T]Reactive value that notifies observers when updated.
- Parameters:
value (T) – Initial value.
- get()
Return the current value.
- Return type:
T
- set(value)
Set the value and notify all observers if it has changed.
- Parameters:
value (T) – New value to set.
- Return type:
None
- to_elem(tag='span')
Create an element whose content is the value of the signal.
The content of the returned element gets updated with the value of the signal.
- trigger()
Trigger all observers without changing the value.
- Return type:
None