Inertia Helpers

litestar_vite.inertia.helpers.lazy(key: str, value_or_callable: None) StaticProp[str, None][source]
litestar_vite.inertia.helpers.lazy(key: str, value_or_callable: T) StaticProp[str, T]
litestar_vite.inertia.helpers.lazy(key: str, value_or_callable: Callable[[...], None] = None) DeferredProp[str, None]
litestar_vite.inertia.helpers.lazy(key: str, value_or_callable: Callable[[...], Coroutine[Any, Any, None]] = None) DeferredProp[str, None]
litestar_vite.inertia.helpers.lazy(key: str, value_or_callable: Callable[[...], T | Coroutine[Any, Any, T]] = None) DeferredProp[str, T]

Wrap an async function to return a DeferredProp.

class litestar_vite.inertia.helpers.StaticProp[source]

Bases: Generic[PropKeyT, StaticT]

A wrapper for static property evaluation.

__init__(key: PropKeyT, value: StaticT) None[source]
class litestar_vite.inertia.helpers.DeferredProp[source]

Bases: Generic[PropKeyT, T]

A wrapper for deferred property evaluation.

__init__(key: PropKeyT, value: Callable[[...], None | T | Coroutine[Any, Any, T | None]] | None = None) None[source]
litestar_vite.inertia.helpers.is_lazy_prop(value: Any) TypeGuard[DeferredProp[Any, Any]][source]

Check if value is a deferred property.

Parameters:

value – Any value to check

Returns:

True if value is a deferred property

Return type:

bool

litestar_vite.inertia.helpers.should_render(value: Any, partial_data: set[str] | None = None) bool[source]

Check if value should be rendered.

Parameters:
  • value – Any value to check

  • partial_data – Optional set of keys for partial rendering

Returns:

True if value should be rendered

Return type:

bool

litestar_vite.inertia.helpers.is_or_contains_lazy_prop(value: Any) bool[source]

Check if value is or contains a deferred property.

Parameters:

value – Any value to check

Returns:

True if value is or contains a deferred property

Return type:

bool

litestar_vite.inertia.helpers.lazy_render(value: T, partial_data: set[str] | None = None, portal: BlockingPortal | None = None) T[source]

Filter deferred properties from the value based on partial data.

Parameters:
  • value – The value to filter

  • partial_data – Keys for partial rendering

  • portal – Optional portal to use for async rendering

Returns:

The filtered value

litestar_vite.inertia.helpers.get_shared_props(request: ASGIConnection[Any, Any, Any, Any], partial_data: set[str] | None = None) dict[str, Any][source]

Return shared session props for a request.

Parameters:
  • request – The ASGI connection.

  • partial_data – Optional set of keys for partial rendering.

  • portal – Optional portal to use for async rendering

Returns:

The shared props.

Return type:

Dict[str, Any]

Note

Be sure to call this before self.create_template_context if you would like to include the flash message details.

litestar_vite.inertia.helpers.share(connection: ASGIConnection[Any, Any, Any, Any], key: str, value: Any) None[source]

Share a value in the session.

Parameters:
  • connection – The ASGI connection.

  • key – The key to store the value under.

  • value – The value to store.

litestar_vite.inertia.helpers.error(connection: ASGIConnection[Any, Any, Any, Any], key: str, message: str) None[source]

Set an error message in the session.

Parameters:
  • connection – The ASGI connection.

  • key – The key to store the error under.

  • message – The error message.