ActiveVariable#
- class osaft.core.variable.ActiveVariable(function_call, name=None)[source]#
Bases:
BaseActiveVariable
Variables that depended on at least one
BaseVariable
- Parameters:
function_call (Callable[[], Any]) – function signature that defines how
ActiveVariable._value
is computedname (None | str, optional) – Name of the variable
Default:None
Public Data Attributes:
Returns the value of the attribute.
Inherited from
BaseActiveVariable
needs_update
Returns if an update is needed for the next value retrieval
Inherited from
BaseVariable
Public Methods:
Inherited from
BaseActiveVariable
is_computed_by
(*variables)Adds the notification dependencies
Inherited from
BaseVariable
notify
()Notifies all items in
BaseVariable._variables_to_notify
that a dependent value changed.
- is_computed_by(*variables)#
Adds the notification dependencies
- Parameters:
variables (
Any
) – variables that are referenced in_update()
- Raises:
TypeError if no arguments are passed
- Return type:
None
- notify()#
Notifies all items in
BaseVariable._variables_to_notify
that a dependent value changed. Just the information of a changed dependency is passed.- Return type:
None
- property name: str#
Returns name of the variable.
- Setter:
sets
_name
- property needs_update: bool#
Returns if an update is needed for the next value retrieval
- property value: Any#
Returns the value of the attribute. If
ActiveVariable.needs_update
is true, it callsActiveVariable._update()
first and then changesActiveVariable._needs_update
to False before returning the value.