lazysignals._signals¶
Classes¶
Functions¶
Module Contents¶
- class Updated¶
A singleton to track the events that have been updated.
- _signals¶
- _updated¶
- enter(signal)¶
- leave(signal)¶
- submit(updated)¶
- class Dependent¶
A singleton to track the signals that have been accessed while executing an effect.
- _effects = []¶
- property is_set¶
- get(dependency)¶
- enter(effect)¶
- leave()¶
- class Effect(fn)¶
A container to hold an effect function.
- _dependencies¶
- _fn¶
- add_dependency(dependency)¶
- update()¶
- 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.