Components as values
Components on the server — design
Status: implemented are markup as HTML, components of the server, their results,
Responsegoing up,Content<T>, component values with a result, decorators with guards, wrappers that take the body and the request context, routes, androoklang/server; the server of the site,site/server/main.rk, is written with them, and the guide has a section on them. The decisions are collected at the end of the document, together with what is not decided yet. Server markup, components androoklang/serverremain experimental in 1.x and may change between releases.
This document builds on components.md: components, decorators, context, components as values. It describes only what is different on the server.
The type of a component value writes its result after the properties, as the type of a function
does; without it, it is Html:
interface Route {
page comp() // a page: Html
open bool // no sign-in needed
}
interface Endpoint {
run comp(id string) any // an API: whatever it returns
}
A tag takes the component from a value as in the browser, <route.page />, and its type is the
result in the type of the value. Unlike the browser, a component value on the server does not need
the order of properties of a function at runtime: it is an async function of an object of
properties and the context, the same for every component.