lightspeed/component

Component contract for Lightspeed applications.

Types

Commands returned from component updates.

pub type Command(msg) {
  NoCommand
  Dispatch(msg)
  Push(isa.Instruction)
}

Constructors

Minimal state/update/render component contract.

pub type Component(model, msg) {
  Component(
    init: fn() -> model,
    update: fn(model, msg) -> #(model, List(Command(msg))),
    render: fn(model) -> Rendered,
  )
}

Constructors

  • Component(
      init: fn() -> model,
      update: fn(model, msg) -> #(model, List(Command(msg))),
      render: fn(model) -> Rendered,
    )

Rendered output from a component.

The first implementation stores HTML as a string. Later versions may replace this with a renderer-neutral tree or static/dynamic segment model.

pub type Rendered {
  Rendered(html: String, fingerprint: String)
}

Constructors

  • Rendered(html: String, fingerprint: String)

Values

pub fn fingerprint(rendered: Rendered) -> String

Extract the static-shape fingerprint from a rendered value.

pub fn html(markup: String) -> Rendered

Construct rendered HTML with a development fingerprint.

pub fn to_html(rendered: Rendered) -> String

Extract HTML from a rendered value.

Search Document