Powered by AppSignal & Oban Pro

near_wallet

near_wallet.livemd

near_wallet

near_wallet

Spiral.Kino.eval!(
  ~S"""
  open lustre
  """,
  timeout: 300_000
)

model

Spiral.Kino.eval!(
  ~S"""
  type model = int
  """,
  timeout: 300_000
)

init

Spiral.Kino.eval!(
  ~S"""
  inl init initial_count : model =
      if initial_count < 0
      then 0
      else initial_count
  """,
  timeout: 300_000
)

msg

Spiral.Kino.eval!(
  ~S"""
  union msg =
      | Incr
      | Decr
  """,
  timeout: 300_000
)

update

Spiral.Kino.eval!(
  ~S"""
  inl update n (model, msg) =
      match msg with
      | Incr => model + n
      | Decr => model - n
  """,
  timeout: 300_000
)

view

Spiral.Kino.eval!(
  ~S"""
  inl view model =
      div [
          style [
              "display", "flex"
          ]
      ] [
          div [
              style [
                  "display", "flex"
                  "flex-direction", "column"
              ]
          ] [
              button [
                  on_click Incr
              ] [
                  text "+"
              ]
              p [
                  style [
                      "text-align", "center"
                  ]
              ] [
                  model |> sm'.obj_to_string |> text
              ]
              button [
                  on_click Decr
              ] [
                  text "-"
              ]
          ]
      ]
  """,
  timeout: 300_000
)

tests

Spiral.Kino.eval!(
  ~S"""
  ///- --test
  ///> gleam -t javascript -d lustre=\">=4.6.0\" lustre_ui=\"1.0.0-rc.1\" gleam_json=\">=2.0.0\"

  simple init (update 1) view
  |> start "#app_"
  """,
  timeout: 300_000
)
Spiral.Kino.eval!(
  ~S"""
  ///- --test
  ///> gleam -t javascript -d lustre=\">=4.6.0\" lustre_ui=\"1.0.0-rc.1\" gleam_json=\">=2.0.0\"

  simple init (update 2) view
  |> start "#app_"
  """,
  timeout: 300_000
)

main

Spiral.Kino.eval!(
  ~S"""
  ///> _

  inl main' (n : int) =
      simple init (update 1) view
      |> start "#app_"

  inl main () =
      $'!main' (0)' : ()
  """,
  timeout: 300_000
)