Module

Solid.Router.Action

Package
purescript-purs-solid
Repository
arazorda/purs-solid

Router actions: mutations the router tracks. When one finishes the router applies its Reply (redirect, revalidation) and, unless the reply says otherwise, revalidates every query on screen. Forms can post to one (H.form { action: formAction save, method: POST }), which works before hydration too. For transactional steps and optimistic values, see Solid.Action.

#RouterAction Source

data RouterAction t0 t1

#routerAction Source

routerAction :: forall a b. String -> (a -> Aff (Reply b)) -> RouterAction a b

name identifies the action (and its form URL); make it unique.

#serverAction Source

serverAction :: forall a b. Serializable a => Serializable b => ServerFunction a (Reply b) -> RouterAction a b

A server function as a router action, identified by the server function; its Reply travels in the response.

#formAction Source

formAction :: forall b. RouterAction FormData b -> String

The URL a <form method="post"> posts to. The router submits the form's FormData.

#useAction Source

useAction :: forall a b. RouterAction a b -> Setup (a -> Aff (Maybe b))

Runs the action. Nothing when it replied with a redirect or a reload. Router 2 deprecates programmatic form action calls. Use a form for tracked submissions or call a server function or Solid.Action directly.

#Submission Source

type Submission a b = { clear :: Effect Unit, error :: Maybe Error, input :: a, result :: Maybe b, retry :: Aff (Maybe b) }

A finished run worth showing: one with a result or an error.

#useSubmissions Source

useSubmissions :: forall a b. RouterAction a b -> Setup (Accessor (Array (Submission a b)))

#Submitting Source

newtype Submitting a

Runs as a submission starts, inside its transaction: make optimistic writes here (Solid.Action.setOptimistic, Solid.Store.updateOptimistic).

Instances

#onSubmit Source

onSubmit :: forall a b. (a -> Submitting Unit) -> RouterAction a b -> RouterAction a b

#onSettled Source

onSettled :: forall a b. (Submission a b -> Effect Unit) -> RouterAction a b -> RouterAction a b

Runs after every submission, including redirects and ones with no result.