lazysignals¶
A library that allows you to run effects whenever state changes. It employs dependency discovery and updates are lazy.
Submodules¶
Classes¶
A container to hold a reactive value. |
Functions¶
Package Contents¶
- class Signal(value=None)¶
A container to hold a reactive value.
- _value = None¶
- _dependents = []¶
- __str__()¶
get a reactive string representation of the contained value
- __repr__()¶
get a (nonreactive) string representation of the container
- property value¶
- Getter:
gets the current value, registering the current effect as a dependent
- Setter:
sets the current value, notifying all dependent effects if it changed
- effect(fn)¶
Run
fn()whenever (relevant) state changes.- Parameters:
fn – The function to run on state changes.
- Returns:
The return value of
fn().
Tip
Use as a function decorator.
- derived(fn)¶
Define a new signal whose value is computed by
fn().- Parameters:
fn – A function to compute the value from.
- Returns:
A new
Signal.
Tip
Use as a function decorator.