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

Class VarData

packages/reflex-base/src/reflex_base/vars/base.py:162–428  ·  view source on GitHub ↗

Metadata associated with a x.

Source from the content-addressed store, hash-verified

160 frozen=True,
161)
162class VarData:
163 """Metadata associated with a x."""
164
165 # The name of the enclosing state.
166 state: str = dataclasses.field(default="")
167
168 # The name of the field in the state.
169 field_name: str = dataclasses.field(default="")
170
171 # Imports needed to render this var
172 imports: ParsedImportTuple = dataclasses.field(default_factory=tuple)
173
174 # Hooks that need to be present in the component to render this var
175 hooks: tuple[str, ...] = dataclasses.field(default_factory=tuple)
176
177 # Dependencies of the var
178 deps: tuple[Var, ...] = dataclasses.field(default_factory=tuple)
179
180 # Position of the hook in the component
181 position: Hooks.HookPosition | None = None
182
183 # Components that are part of this var
184 components: tuple[BaseComponent, ...] = dataclasses.field(default_factory=tuple)
185
186 # App-level wrapper components this var requires when used (priority, component).
187 # Higher priority wraps further out, matching Component._get_app_wrap_components semantics.
188 app_wraps: tuple[tuple[int, BaseComponent], ...] = dataclasses.field(
189 default_factory=tuple
190 )
191
192 def __init__(
193 self,
194 state: str = "",
195 field_name: str = "",
196 imports: ImmutableImportDict | ImmutableParsedImportDict | None = None,
197 hooks: Mapping[str, VarData | None] | Sequence[str] | str | None = None,
198 deps: list[Var] | None = None,
199 position: Hooks.HookPosition | None = None,
200 components: Iterable[BaseComponent] | None = None,
201 app_wraps: Iterable[tuple[int, BaseComponent]] | None = None,
202 ):
203 """Initialize the var data.
204
205 Args:
206 state: The name of the enclosing state.
207 field_name: The name of the field in the state.
208 imports: Imports needed to render this var.
209 hooks: Hooks that need to be present in the component to render this var.
210 deps: Dependencies of the var for useCallback.
211 position: Position of the hook in the component.
212 components: Components that are part of this var.
213 app_wraps: App-level wrapper components this var requires when used.
214 """
215 if isinstance(hooks, str):
216 hooks = [hooks]
217 if not isinstance(hooks, dict):
218 hooks = dict.fromkeys(hooks or [])
219 immutable_imports: ParsedImportTuple = tuple(

Callers 15

createMethod · 0.90
add_hooksMethod · 0.90
banner.pyFile · 0.90
createMethod · 0.90
add_hooksMethod · 0.90
createMethod · 0.90
add_hooksMethod · 0.90
createMethod · 0.90
upload.pyFile · 0.90
createMethod · 0.90
createMethod · 0.90

Calls

no outgoing calls