glamour/app

Types

Describes a Glamour-enabled Lustre application.

Glamour assumes that the Lustre application’s start_args type is the same as its model. On the client we will pass the reclaimed model into lustre.start so the runtime can attach event listeners without performing a throwaway re-render.

Provide JSON encoder/decoder functions so Glamour can transport the initial model between server and client.

pub type Spec(model, msg) {
  Spec(
    app: lustre.App(model, model, msg),
    view: fn(model) -> @internal Element(msg),
    encode: fn(model) -> json.Json,
    decoder: decode.Decoder(model),
    selector: String,
    state_script_id: String,
  )
}

Constructors

  • Spec(
      app: lustre.App(model, model, msg),
      view: fn(model) -> @internal Element(msg),
      encode: fn(model) -> json.Json,
      decoder: decode.Decoder(model),
      selector: String,
      state_script_id: String,
    )

Values

pub fn new(
  app app: lustre.App(model, model, msg),
  view view: fn(model) -> @internal Element(msg),
  encode encode: fn(model) -> json.Json,
  decoder decoder: decode.Decoder(model),
) -> Spec(model, msg)

Create a new Glamour spec using the provided Lustre application, JSON encoder, and decoder. The default mount selector is #app and the embedded state script id is glamour-state.

pub fn selector(
  selector: String,
) -> fn(Spec(model, msg)) -> Spec(model, msg)

Produce an option so the selector can be customised ergonomically with option.Option pipelines.

pub fn state_script_id(
  id: String,
) -> fn(Spec(model, msg)) -> Spec(model, msg)

Produce an option so the state script id can be adjusted via pipelines.

pub fn with_selector(
  spec: Spec(model, msg),
  selector selector: String,
) -> Spec(model, msg)

Change the CSS selector Glamour should target when claiming the DOM.

pub fn with_state_script_id(
  spec: Spec(model, msg),
  id: String,
) -> Spec(model, msg)

Change the id used for the embedded JSON script tag.

Search Document