duck.html.components.core.systemยถ
Manages the registration and lifecycle of HTML components, and enables communication with the browser via WebSocket to dispatch events and execute JavaScript in real-time.
Module Contentsยถ
Classesยถ
LivelyComponentSystem class. |
APIยถ
- class duck.html.components.core.system.LivelyComponentSystemยถ
LivelyComponentSystem class.
- classmethod add_to_registry(uid: str, component: duck.html.components.Component) Noneยถ
Add a component to the internal registry.
- Parameters:
uid โ The unique identifier for the component.
component โ The component instance to register.
- Raises:
AlreadyInRegistry โ If the component is already registered with the same UID.
ComponentSystemError โ If the provided component is not a valid Component instance.
- classmethod get_from_registry(root_uid: str, uid: str, default: Optional[Any] = None) Optional[duck.html.components.Component]ยถ
Retrieve a component from the registry using its UID.
- Parameters:
root_uid โ The UID of the root component group.
uid โ The unique identifier of the component.
default โ The value to return if the component is not found.
- Returns:
The component if found, otherwise the default value.
- Return type:
Component | Any
- classmethod get_html_tags() List[duck.html.components.templatetags.ComponentTag]ยถ
Returns loaded HTML component template tags defined in
settings.py.- Raises:
ComponentSystemError โ If any component cannot be imported or instantiated.
- classmethod get_urlpatterns() List[duck.urls.URLPattern]ยถ
Returns the appropriate URL patterns for the whole system.
- classmethod get_websocket_view_cls() Typeยถ
Returns the WebSocket view class responsible for handling communication between the server and the client, including event dispatching.
- Returns:
The WebSocket view class used for client communication.
- Return type:
Type
- classmethod is_active() boolยถ
Returns boolean on whether the component system is active.
- registry: duck.utils.caching.InMemoryCacheยถ
โInMemoryCache(โฆ)โ
Mapping of UIDs to components.
Format: {root_uid: {root_uid: component, child_uid: component, โฆ}}
- registry_lockยถ
โLock(โฆ)โ
Lock for avoiding race conditions in multiple threads, especially in worker threads.