xdas.atoms.State#
- class xdas.atoms.State(state)[source]#
A class to declare a new state or to update a preexising one into an Atom object.
- Parameters:
state (Any) – The state to be passed to the Atom object.
Examples
In practice the State object is used when implementing new Atom objects. Bellow a dummy example without any class declaration.
>>> from xdas.atoms import Atom, State
Let’s create an empty Atom object:
>>> self = Atom() >>> self.state {}
We can declare and initialize a new state:
>>> self.count = State(0) >>> self.state {'count': 0}
To update the state, we must use the State object again. The state is updated by:
>>> self.count = State(self.count + 1) >>> self.state {'count': 1}
Methods
__init__(state)