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

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:
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.