lazysignals._signals ==================== .. py:module:: lazysignals._signals Classes ------- .. autoapisummary:: lazysignals._signals.Updated lazysignals._signals.Dependent lazysignals._signals.Effect lazysignals._signals.Signal Functions --------- .. autoapisummary:: lazysignals._signals.effect lazysignals._signals.derived Module Contents --------------- .. py:class:: Updated A singleton to track the events that have been updated. .. py:attribute:: _signals .. py:attribute:: _updated .. py:method:: enter(signal) .. py:method:: leave(signal) .. py:method:: submit(updated) .. py:class:: Dependent A singleton to track the signals that have been accessed while executing an effect. .. py:attribute:: _effects :value: [] .. py:property:: is_set .. py:method:: get(dependency) .. py:method:: enter(effect) .. py:method:: leave() .. py:class:: Effect(fn) A container to hold an effect function. .. py:attribute:: _dependencies .. py:attribute:: _fn .. py:method:: add_dependency(dependency) .. py:method:: update() .. py:class:: Signal(value=None) A container to hold a reactive value. .. py:attribute:: _value :value: None .. py:attribute:: _dependents :value: [] .. py:method:: __str__() get a reactive string representation of the contained value .. py:method:: __repr__() get a (nonreactive) string representation of the container .. py: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 .. py:function:: effect(fn) Run ``fn()`` whenever (relevant) state changes. :param fn: The function to run on state changes. :returns: The return value of ``fn()``. .. tip:: Use as a function decorator. .. py:function:: derived(fn) Define a new signal whose value is computed by ``fn()``. :param fn: A function to compute the value from. :returns: A new ``Signal``. .. tip:: Use as a function decorator.