Skip to content

Assigns

[Source]

Key-value store with change tracking for LiveView state.

Values are stored as TemplateValue via the templates library's TemplateValues container. Plain strings are automatically wrapped.

The framework checks changed() after each event handler to determine whether a re-render is needed, and calls clear_changes() after rendering.

class ref Assigns

Constructors

create

[Source]

new ref create()
: Assigns ref^

Returns


Public Functions

update

[Source]

Set a value and mark assigns as changed.

fun ref update(
  key: String val,
  value: (String val | TemplateValue box))
: None val

Parameters

Returns


apply

[Source]

Look up a value by key.

fun box apply(
  key: String val)
: TemplateValue box ?

Parameters

Returns


changed

[Source]

True if any assign was modified since the last clear_changes().

fun box changed()
: Bool val

Returns


clear_changes

[Source]

Reset change tracking. Called by the framework after rendering.

fun ref clear_changes()
: None val

Returns


template_values

[Source]

Return the backing TemplateValues for use with HtmlTemplate.render() or HtmlTemplate.render_to().

fun box template_values()
: TemplateValues box

Returns


component_html

[Source]

Look up the rendered HTML for a registered component.

Use this in render() or render_parts() to include component output in the parent's HTML. The returned string is already escaped by the component's own HtmlTemplate -- insert it as TemplateValue.unescaped() in the parent's template values.

fun box component_html(
  id: String val)
: String val ?

Parameters

Returns


render_values

[Source]

Create a writable child scope of the backing template values.

Use this in render() or render_parts() to overlay component HTML or computed values onto the existing assigns without modifying the underlying state. The child scope falls through to the parent for lookups, so all existing assigns remain accessible.

fun box render_values()
: TemplateValues ref

Returns