lightspeed/component/helpers

Ergonomic helpers for Lightspeed components.

Values

pub fn dispatch(msg: msg) -> component.Command(msg)

Construct a dispatch command.

pub fn html_with_fingerprint(
  markup: String,
  fingerprint: String,
) -> component.Rendered

Render markup with an explicit fingerprint.

pub fn make(
  init init: fn() -> model,
  update update: fn(model, msg) -> #(
    model,
    List(component.Command(msg)),
  ),
  render render: fn(model) -> component.Rendered,
) -> component.Component(model, msg)

Construct a component from init/update/render functions.

pub fn map_command(
  command: component.Command(inner),
  with: fn(inner) -> outer,
) -> component.Command(outer)

Map the message type inside a component command.

pub fn map_commands(
  commands: List(component.Command(inner)),
  with: fn(inner) -> outer,
) -> List(component.Command(outer))

Map message type for a list of commands.

pub fn navigate(to: String) -> component.Command(msg)

Construct a navigate command.

pub fn no_effect(
  model: model,
) -> #(model, List(component.Command(msg)))

Return an update result with no commands.

pub fn patch(
  target: String,
  html: String,
) -> component.Command(msg)

Construct a patch command.

pub fn push(
  instruction: isa.Instruction,
) -> component.Command(msg)

Construct a pushed ISA instruction command.

pub fn shutdown(reason: String) -> component.Command(msg)

Construct a shutdown command.

pub fn subscribe(topic: String) -> component.Command(msg)

Construct a subscription command.

pub fn unsubscribe(topic: String) -> component.Command(msg)

Construct an unsubscription command.

Search Document