duck.html.components.utils.staticΒΆ
Module for creating static components.
Module ContentsΒΆ
FunctionsΒΆ
This is a nested function which you can use directly with component classes
without the need of using |
|
Decorator for declaring static components. |
APIΒΆ
- duck.html.components.utils.static.StaticComponent(component_cls: Type, **static_options)[source]ΒΆ
This is a nested function which you can use directly with component classes without the need of using
static_componentdecorator.Example:
static_btn_func = StaticComponent( Button, cache_targets=["id", "text"], ) # Returns function for retrieving or creating the button instance. btn = statc_btn_func(id="my-btn", text="Hello world") btn.is_from_cache() # Returns False for the first time and True otherwise btn.is_a_copy() # Returns True by default. btn.is_a_copy() # True if not isinstance of Page component
- duck.html.components.utils.static.static_component(use_caching: bool = True, cache_targets: Optional[List[Union[str, Callable]]] = None, cache_backend: Optional[Any] = None, cache_expiry: Optional[float] = None, cache_namespace: Optional[Union[str, Callable]] = None, cache_ignore_args: Optional[List[int]] = None, cache_ignore_kwargs: Optional[List[str]] = None, skip_cache_attr: str = 'skip_cache', on_cache_result: Optional[Callable] = None, return_copy: bool = True)[source]ΒΆ
Decorator for declaring static components.
Example:
@static_compoment() class MyStaticButton(Button): pass btn = MyStaticButton(text="hello world") # New instance btn.is_frozen() # True btn.is_from_cache() # False for the first time btn.is_a_copy() # True if not isinstance of Page component btn = MyStaticButton(text="hello world") btn.is_from_cache() # TrueDo help on
cached_componentdecorator for more information.