Std.Spa
Std.Spa — client-side TEA (Sky.Spa), the browser counterpart of Std.Live.
Types
type AppConfig model msg
type Route
Values
app : AppConfig model msg -> Task Error ()
Run the Sky.Spa client app. Returns a `Task` so `main` forces it exactly
config : { init : a -> ( model, Cmd msg ) , update : msg -> model -> ( model, Cmd msg ) , view : model -> Html msg , subscriptions : model -> Sub msg } -> AppConfig model msg
Build the client app config from the four required TEA fields. Attach
followUps : List msg -> Cmd msg
Dispatch a list of Msgs, in order, through the client `update` — the
getJson : Codec a -> String -> (Result Error a -> msg) -> Cmd msg
`getJson codec url toMsg` — GET `url` from the stateless backend and decode
postJson : Codec body -> Codec a -> String -> body -> (Result Error a -> msg) -> Cmd msg
`postJson bodyCodec respCodec url payload toMsg` — encode `payload` with
reportError : Error -> Cmd msg
Report an `Error` on the client console without dispatching anything (the
reportRpcFailure : Error -> Cmd msg
Report a failed server-branch RPC on the client console without
route : String -> page -> Route
`route path page` — register a client-side page route. `path` may contain
routeInt : String -> (Int -> page) -> Route
`routeInt path toPage` — a route whose `:param` segment(s) are **Ints**.
rpc : Codec body -> Codec a -> String -> body -> (Result Error a -> msg) -> Cmd msg
`rpc bodyCodec respCodec url body toMsg` — the auto-split's server-branch
rpcHold : Codec body -> Codec a -> String -> body -> (Result Error a -> msg) -> Cmd msg
`rpcHold bodyCodec respCodec url body toMsg` — `rpc` for a server branch
rpcWith : Codec body -> Codec a -> String -> body -> Cmd msg -> (Result Error a -> msg) -> Cmd msg
`rpcWith bodyCodec respCodec url body residual toMsg` — `rpc` plus a CLIENT
serverRoute : String -> Route
`serverRoute spec` — a path the BACKEND serves (`"GET /logout"`, `"/webhook"`),
withClientCrypto : AppConfig model msg -> AppConfig model msg
Keep end-to-end key material on the device (a build-time marker; at run
withGuard : (msg -> model -> Result Error ()) -> AppConfig model msg -> AppConfig model msg
Attach a per-Msg guard — `guard msg model` returns `Err` to reject the
withHead : (model -> List (Html msg)) -> AppConfig model msg -> AppConfig model msg
Set the document `<head>` builder — `head model` returns the `<head>`
withModelDecoder : (String -> Result Error model) -> AppConfig model msg -> AppConfig model msg
Set the model DECODER — `decode json` turns the SSR-embedded `#sky-model`
withModelEncoder : (model -> String) -> AppConfig model msg -> AppConfig model msg
Set the model ENCODER — `encode model` turns the WHOLE typed model into the
withNotFound : page -> AppConfig model msg -> AppConfig model msg
The page to show when no route matches (the 404). Without it, an unmatched
withOnNavigate : (page -> msg) -> AppConfig model msg -> AppConfig model msg
Hook fired on in-app navigation (initial mount, intercepted click,
withPersistDecoder : (String -> Result Error model) -> AppConfig model msg -> AppConfig model msg
Set the decoder the client uses ONLY to restore its localStorage copy of the
withPersistProtectedFields : List String -> AppConfig model msg -> AppConfig model msg
Set the PROTECTED field names — the model fields whose value MUST come from
withPersistSeedFields : List String -> AppConfig model msg -> AppConfig model msg
Set the model fields the SSR seed settles on EVERY page (the fields the
withRoutes : List Route -> AppConfig model msg -> AppConfig model msg
Register the client-side routes. The runtime resolves `location.pathname`