cmpt_lazy

class janim.utils.cmpt_lazy.Expired

Bases: object

janim.utils.cmpt_lazy.cmpt_lazy_method(func: T, *, recurse_up: bool = False, recurse_down: bool = False) T
janim.utils.cmpt_lazy.cmpt_lazy_method(func: None = None, *, recurse_up: bool = False, recurse_down: bool = False) Callable[[T], T]

Used to recompute values returned by component methods only when needed, improving performance.

When recomputation is needed, self.bind.reset_computed_for is used to reset the computed state. Subsequent calls to func will then recompute and return the value.

Note: No caching is provided if the component is not bound to an item.

class janim.utils.cmpt_lazy.CmptSignal(func: Callable[Concatenate[T, P], R])

Bases: Generic[T, P, R]

self_refresh(func: Fn, *, key: str = '') Fn
self_refresh(func: None = None, *, key: str = '') Callable[[Fn], Fn]

The decorated method is marked for recomputation when a Signal is triggered.

connect(sender: Component, func: Callable, *, key: str = '') None

Makes func be called when a Signal is triggered.

emit(sender: Component, *args, key: str = '', **kwargs)