mendraw/datasource

Provides typed snapshots of datasource-bound widget properties.

A snapshot captures one data source, nested object list, or item-bound attribute as an immutable Gleam value. Widgets can branch on the captured state without inspecting Mendix runtime JavaScript shapes:

import mendraw/datasource

case datasource.capture(props, "dataSource") {
  datasource.Available(_, data) -> render_rows(data.items)
  datasource.Loading(_) -> render_loading()
  datasource.PropertyAbsent(_) | datasource.Unavailable(_) -> render_empty()
}

Types

The stable data captured from one available data source.

pub type Data {
  Data(
    items: List(mendix.ObjectItem),
    offset: Int,
    limit: Int,
    has_more_items: option.Option(Bool),
    total_count: option.Option(Int),
  )
}

Constructors

A typed entry of an object-array property such as widget columns.

pub type ObjectListEntry

Describes why an object-array property could not be read.

pub type ObjectListError {
  ObjectPropertyMissing(key: String)
  ObjectPropertyNotAList(key: String)
}

Constructors

  • ObjectPropertyMissing(key: String)

    The widget props did not contain the requested property.

  • ObjectPropertyNotAList(key: String)

    The property exists but is not an array of configuration objects.

One immutable capture of a datasource-bound property.

pub type Snapshot {
  PropertyAbsent(key: String)
  Loading(key: String)
  Unavailable(key: String)
  Available(key: String, data: Data)
}

Constructors

  • PropertyAbsent(key: String)

    The widget props did not contain the requested property.

  • Loading(key: String)

    The data source reported that items are still loading.

  • Unavailable(key: String)

    The data source exists but reported an unsupported state.

  • Available(key: String, data: Data)

    The data source is available and carries a stable ordered item view.

Values

pub fn attribute_value(
  attr attr: list_attribute.ListAttributeValue,
  item item: mendix.ObjectItem,
) -> editable_value.EditableValue

Resolves a datasource-bound attribute value for one object item.

The returned editable value reuses the typed status, value, display, and read-only accessors from mendraw/mendix/editable_value.

pub fn capture(
  props props: mendix.JsProps,
  key key: String,
) -> Snapshot

Captures one datasource property with its state, ordering, and page info.

pub fn count(snapshot snapshot: Snapshot) -> Int

Returns the stable captured item count.

pub fn entry_field_string(
  entry entry: ObjectListEntry,
  field field: String,
) -> option.Option(String)

Reads one string field of an object-array entry.

pub fn items(
  snapshot snapshot: Snapshot,
) -> List(mendix.ObjectItem)

Returns the captured items; non-available snapshots are empty.

pub fn object_list(
  props props: mendix.JsProps,
  key key: String,
) -> Result(List(ObjectListEntry), ObjectListError)

Reads an object-array property such as widget column definitions.

Search Document