//// Illustrious is a meta framework built on top of lustre. It supports: //// * server-side rendering //// * turning into a SPA by using client-side routing after initial load //// * automatic data hydration when a page is first loaded & on navigation import gleam/dynamic.{type Dynamic} import gleam/option.{type Option} import illustrious/state.{type IllustriousAction} import lustre/effect.{type Effect} import lustre/element.{type Element} /// The path portion of a URL, split by each directory separator (`/`) pub type Path = state.Path /// The router function takes in the split path & the app state and returns the /// actual elements to render, or None if there is nothing to render (404) pub type Router(state, action) = fn(Path, state) -> Option(Element(IllustriousAction(action))) /// The updater function takes in the current application state and an action /// and returns the new application state and an effect (possibly the `none` /// effect) which get executed pub type Updater(state, action) = fn(state, action) -> #(state, Effect(IllustriousAction(action))) /// The decoder function which takes in a JSON-decoded dynamic from the /// initializer or server loader and returns an effect which can be executed in /// order to populate the application state before rendering pub type Decoder(action) = fn(Dynamic) -> Effect(IllustriousAction(action)) pub type View(model, action) = fn(Path, model) -> element.Element(IllustriousAction(action))