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

Method get_state

reflex/state.py:1724–1742  ·  view source on GitHub ↗

Get an instance of the state associated with this token. Allows for arbitrary access to sibling states from within an event handler. Args: state_cls: The class of the state. Returns: The instance of state_cls associated with this state's client_toke

(self, state_cls: type[T_STATE])

Source from the content-addressed store, hash-verified

1722 return substate
1723
1724 async def get_state(self, state_cls: type[T_STATE]) -> T_STATE:
1725 """Get an instance of the state associated with this token.
1726
1727 Allows for arbitrary access to sibling states from within an event handler.
1728
1729 Args:
1730 state_cls: The class of the state.
1731
1732 Returns:
1733 The instance of state_cls associated with this state's client_token.
1734 """
1735 # Fast case - if this state instance is already cached, get_substate from root state.
1736 try:
1737 return self._get_state_from_cache(state_cls)
1738 except ValueError:
1739 pass
1740
1741 # Slow case - fetch missing parent states from redis.
1742 return await self._get_state_from_redis(state_cls)
1743
1744 async def get_var_value(self, var: Var[VAR_TYPE]) -> VAR_TYPE:
1745 """Get the value of an rx.Var from another state.

Callers 15

get_var_valueMethod · 0.95
clone_stateMethod · 0.45
_rehydrateMethod · 0.45
_execute_eventMethod · 0.45
triple_countMethod · 0.45
get_other_stateMethod · 0.45
_triple_countMethod · 0.45
greetingMethod · 0.45
linked_toMethod · 0.45
fetch_shared_noteMethod · 0.45
bump_counter_bgMethod · 0.45
bump_counter_yieldMethod · 0.45

Calls 2

_get_state_from_cacheMethod · 0.95
_get_state_from_redisMethod · 0.95

Tested by 15

triple_countMethod · 0.36
get_other_stateMethod · 0.36
_triple_countMethod · 0.36
greetingMethod · 0.36
linked_toMethod · 0.36
fetch_shared_noteMethod · 0.36
bump_counter_bgMethod · 0.36
bump_counter_yieldMethod · 0.36
race_val_0Method · 0.36
race_val_1Method · 0.36
race_val_2Method · 0.36
race_val_3Method · 0.36