MCPcopy Index your code
hub / github.com/reactive-python/reactpy / _ModelState

Class _ModelState

src/py/reactpy/reactpy/core/layout.py:592–663  ·  view source on GitHub ↗

State that is bound to a particular element within the layout

Source from the content-addressed store, hash-verified

590
591
592class _ModelState:
593 """State that is bound to a particular element within the layout"""
594
595 __slots__ = (
596 "__weakref__",
597 "_parent_ref",
598 "_render_semaphore",
599 "children_by_key",
600 "index",
601 "key",
602 "life_cycle_state",
603 "model",
604 "patch_path",
605 "targets_by_event",
606 )
607
608 def __init__(
609 self,
610 parent: _ModelState | None,
611 index: int,
612 key: Any,
613 model: Ref[VdomJson],
614 patch_path: str,
615 children_by_key: dict[Key, _ModelState],
616 targets_by_event: dict[str, str],
617 life_cycle_state: _LifeCycleState | None = None,
618 ):
619 self.index = index
620 """The index of the element amongst its siblings"""
621
622 self.key = key
623 """A key that uniquely identifies the element amongst its siblings"""
624
625 self.model = model
626 """The actual model of the element"""
627
628 self.patch_path = patch_path
629 """A "/" delimited path to the element within the greater layout"""
630
631 self.children_by_key = children_by_key
632 """Child model states indexed by their unique keys"""
633
634 self.targets_by_event = targets_by_event
635 """The element's event handler target strings indexed by their event name"""
636
637 # === Conditionally Available Attributes ===
638 # It's easier to conditionally assign than to force a null check on every usage
639
640 if parent is not None:
641 self._parent_ref = weakref(parent)
642 """The parent model state"""
643
644 if life_cycle_state is not None:
645 self.life_cycle_state = life_cycle_state
646 """The state for the element's component (if it has one)"""
647
648 @property
649 def is_component_state(self) -> bool:

Callers 6

_new_root_model_stateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected