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

Method update_vars_internal

reflex/state.py:2421–2439  ·  view source on GitHub ↗

Apply updates to fully qualified state vars. The keys in `vars` should be in the form of `{state.get_full_name()}.{var_name}`, and each value will be set on the appropriate substate instance. This function is primarily used to apply cookie and local storage updates

(self, vars: dict[str, Any])

Source from the content-addressed store, hash-verified

2419 """Substate for handling internal state var updates."""
2420
2421 async def update_vars_internal(self, vars: dict[str, Any]) -> None:
2422 """Apply updates to fully qualified state vars.
2423
2424 The keys in `vars` should be in the form of `{state.get_full_name()}.{var_name}`,
2425 and each value will be set on the appropriate substate instance.
2426
2427 This function is primarily used to apply cookie and local storage
2428 updates from the frontend to the appropriate substate.
2429
2430 Args:
2431 vars: The fully qualified vars and values to update.
2432 """
2433 for var, value in vars.items():
2434 state_name, _, var_name = var.rpartition(".")
2435 var_name = var_name.removesuffix(FIELD_MARKER)
2436 var_state_cls = State.get_class_substate(state_name)
2437 if var_state_cls._is_client_storage(var_name):
2438 var_state = await self.get_state(var_state_cls)
2439 setattr(var_state, var_name, value)
2440
2441
2442class OnLoadInternalState(State):

Callers

nothing calls this directly

Calls 4

itemsMethod · 0.80
get_class_substateMethod · 0.80
_is_client_storageMethod · 0.80
get_stateMethod · 0.45

Tested by

no test coverage detected