meadow

Types

This type is used to have the signal available both on the client and the server. Just provide an initial value and a fun name. The name should start with the path to the page you are working on. The name can only contain alphanumeric characters and dashes.

pub type Signal(a) {
  Signal(value: a, name: String)
}

Constructors

  • Signal(value: a, name: String)

Functions

pub fn html(: a) -> Nil

JavaScript:

Render the Glare code to the body of the page.

Erlang:

Does nothing, but is provided for ease of use. This makes sure you don’t need the @target(javascript) annotation.

pub fn server_signal(
  prev: List(Handler(a)),
  signal: Signal(a),
  handle: fn(a) -> a,
) -> List(Handler(a))

Erlang:

Initialize the signal on the server side. This function is called by piping the argument of the server method to it. It also takes a handler function that should return the new value of the signal.

Call it like this: s |> server_signal(count_signal, fn(a) { a + 1 })

JavaScript:

pub fn server_signal(signal: Signal(a)) -> #(fn() -> a, fn(a) -> Nil) Initialize the signal on the client side. Returns a get and set function in that order.

Call it like this: let #(count, set_count) = server_signal(count_signal)

pub fn start_server(
  routes: List(fn(List(Handler(Int))) -> List(Handler(Int))),
) -> Nil

Erlang:

Start the server. This should be the only function called from the main function. Its argument should be a list of all the server functions in your project.

JavaScript:

Does nothing, but is provided for ease of use. This makes sure you don’t need the @target(erlang) annotation.

Search Document