MCPcopy
hub / github.com/reflex-dev/reflex / get_substate

Method get_substate

reflex/state.py:1617–1638  ·  view source on GitHub ↗

Get the substate. Args: path: The path to the substate. Returns: The substate. Raises: ValueError: If the substate is not found.

(self, path: Sequence[str])

Source from the content-addressed store, hash-verified

1615 substate._reset_client_storage()
1616
1617 def get_substate(self, path: Sequence[str]) -> BaseState:
1618 """Get the substate.
1619
1620 Args:
1621 path: The path to the substate.
1622
1623 Returns:
1624 The substate.
1625
1626 Raises:
1627 ValueError: If the substate is not found.
1628 """
1629 if len(path) == 0:
1630 return self
1631 if path[0] == self.get_name():
1632 if len(path) == 1:
1633 return self
1634 path = path[1:]
1635 if path[0] not in self.substates:
1636 msg = f"Invalid path: {path}"
1637 raise ValueError(msg)
1638 return self.substates[path[0]].get_substate(path[1:])
1639
1640 @classmethod
1641 def _get_potentially_dirty_states(cls) -> set[type[BaseState]]:

Callers 11

child_stateFunction · 0.45
child_state2Function · 0.45
grandchild_stateFunction · 0.45
test_get_substateFunction · 0.45
test_state_proxyFunction · 0.45
test_get_stateFunction · 0.45
_get_state_from_cacheMethod · 0.45

Calls 1

get_nameMethod · 0.95

Tested by 9

child_stateFunction · 0.36
child_state2Function · 0.36
grandchild_stateFunction · 0.36
test_get_substateFunction · 0.36
test_state_proxyFunction · 0.36
test_get_stateFunction · 0.36