Skip to content
PACKAGES

State

Kind: class

Source: src/graphrefly/_facade.py:641

A state node: the only place host input enters a graph.

set(value: T | Callable[[T], T]) -> None

Write a value; given an updater, compute it from the state’s value when the write runs in request order.

An updater is a function, a method or a functools.partial; a class or an object with __call__ is written as a value. The updater gets graphrefly.SENTINEL when the state holds no value (not None, which is valid DATA in Python; TS passes undefined and Rust None for the same absence). An updater that returns the value it was given writes nothing: the same object, or an equal bool, int, float, str or bytes (NaN counts as itself, -0.0 differs from 0.0). To store a function as the value, wrap it: set(lambda _: fn) (graphrefly-py:D11).

Source: src/graphrefly/_facade.py:644

invalidate() -> None

Remove the state’s value and invalidate its dependents.

Source: src/graphrefly/_facade.py:675

complete() -> None

End the state with COMPLETE; later host input is refused.

Source: src/graphrefly/_facade.py:682

error(error: object) -> None

End the state with ERROR carrying error; later host input is refused.

Source: src/graphrefly/_facade.py:689