← all modules

Std.Spa

Std.Spa
  Std.Spa — client-side TEA (Sky.Spa), the browser counterpart of Std.Live.

Types
  type AppConfig model msg
  type Route page

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
  readInitScrolls : String -> Result Error ( String, String )
      Internal generated init-RPC plumbing. Decode its versioned follow-up and
  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
  returnedScrolls : String -> Cmd msg
      Internal generated RPC plumbing: reconstruct post-render scroll commands
  route : String -> page -> Route page
      `route path page` — register a client-side page route. Put literal
  routeInt : String -> (Int -> page) -> Route page
      `routeInt path toPage` — a route whose `:param` segment(s) are **Ints**.
  routeParam : String -> (String -> page) -> Route page
      `routeParam path make` — a route whose `:param` segment is passed to
  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
  rpcScrollHold : Codec body -> Codec a -> String -> body -> (Result Error a -> msg) -> Cmd msg
      Internal auto-split DOM-effect barrier. Like rpcHold, but commuting
  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
  scrollRpcScope : Cmd msg -> Cmd msg
      Internal generated mixed-command scope. Its interpreter captures the
  serverRoute : String -> Route page
      `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>`
  withHoldFree : List String -> AppConfig model msg -> AppConfig model msg
      The input Msgs that may run while a given hold RPC is in flight
  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
  withPersistExcludeFields : List String -> AppConfig model msg -> AppConfig model msg
      The model fields the client never stores in localStorage (v0.29.0). A
  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 page) -> AppConfig model msg -> AppConfig model msg
      Register the client-side routes. The runtime resolves `location.pathname`