Module

Solid.Control

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

Control flow. A branch is only created while it's shown; render callbacks run in Setup, so each item or branch owns its state until it leaves.

Conditions and lists are an Accessor or an Async (Tracked f). A bare pure x could be either, so when (pure b) doesn't compile ("the instance head contains unknown type variables"): a fixed condition is a plain if b then … else empty, or annotate it (pure b :: Accessor Boolean).

#when Source

when :: forall f. Tracked f => f Boolean -> JSX -> JSX

#whenElse Source

whenElse :: forall f. Tracked f => f Boolean -> JSX -> JSX -> JSX

#showMaybe Source

showMaybe :: forall f a. Tracked f => f (Maybe a) -> (Accessor a -> Setup JSX) -> JSX

The branch is created once and reads the current value through the accessor.

#showMaybeElse Source

showMaybeElse :: forall f a. Tracked f => f (Maybe a) -> (Accessor a -> Setup JSX) -> JSX -> JSX

#showMaybeKeyed Source

showMaybeKeyed :: forall f a. Tracked f => f (Maybe a) -> (a -> Setup JSX) -> JSX

Re-creates the branch whenever the value changes (by identity).

#showMaybeKeyedElse Source

showMaybeKeyedElse :: forall f a. Tracked f => f (Maybe a) -> (a -> Setup JSX) -> JSX -> JSX

#forEach Source

forEach :: forall f a. Tracked f => StableIdentity a => f (Array a) -> (a -> Accessor Int -> Setup JSX) -> JSX

Keyed by the items themselves: an item's view is created once and moved with the item. For primitives and store cursors (Store.items).

#forEachElse Source

forEachElse :: forall f a. Tracked f => StableIdentity a => f (Array a) -> (a -> Accessor Int -> Setup JSX) -> JSX -> JSX

#forEachByReference Source

forEachByReference :: forall f a. Tracked f => f (Array a) -> (a -> Accessor Int -> Setup JSX) -> JSX

forEach for any values, keyed by reference (===). Rows survive only while the list keeps the same values (moving or filtering them, not rebuilding them).

#forEachByReferenceElse Source

forEachByReferenceElse :: forall f a. Tracked f => f (Array a) -> (a -> Accessor Int -> Setup JSX) -> JSX -> JSX

#forEachUnkeyed Source

forEachUnkeyed :: forall f a. Tracked f => f (Array a) -> (Accessor a -> Int -> Setup JSX) -> JSX

Keyed by position: the view at each index stays and its item accessor updates.

#forEachUnkeyedElse Source

forEachUnkeyedElse :: forall f a. Tracked f => f (Array a) -> (Accessor a -> Int -> Setup JSX) -> JSX -> JSX

#forEachBy Source

forEachBy :: forall f a k. Tracked f => (a -> k) -> f (Array a) -> (Accessor a -> Accessor Int -> Setup JSX) -> JSX

Keyed by a derived key (e.g. _.id); the item accessor updates to the newest value.

#forEachByElse Source

forEachByElse :: forall f a k. Tracked f => (a -> k) -> f (Array a) -> (Accessor a -> Accessor Int -> Setup JSX) -> JSX -> JSX

#repeat Source

repeat :: forall f. Tracked f => f Int -> (Int -> Setup JSX) -> JSX

Renders the indices 0 .. count - 1.

#repeatElse Source

repeatElse :: forall f. Tracked f => f Int -> (Int -> Setup JSX) -> JSX -> JSX

#Case Source

newtype Case

#match Source

match :: forall f. Tracked f => f Boolean -> JSX -> Case

#matchMaybe Source

matchMaybe :: forall f a. Tracked f => f (Maybe a) -> (a -> Setup JSX) -> Case

#switch Source

switch :: Array Case -> JSX -> JSX

The first case whose condition holds, else fallback.

#caseOn Source

caseOn :: forall f a k. Tracked f => Eq k => (a -> k) -> f a -> (a -> Accessor a -> Setup JSX) -> JSX

Renders a branch per key of value, rebuilding it only when the key changes (by Eq). The branch gets the value it was built for, to pattern match on, and the accessor for later changes under the same key:

caseOn constructorName page \current latest -> case current of
  Home -> homeView
  Profile _ -> profileView latest

#constructorName Source

constructorName :: forall a rep. Generic a rep => ConstructorName rep => a -> String

The name of a value's constructor, e.g. to key caseOn by constructor.

#ConstructorName Source

class ConstructorName rep  where

Members

Instances

#loading Source

loading :: JSX -> JSX -> JSX

Shows fallback only on the first load; later updates keep the current content visible (use Solid.Async.isPending to show them).

#loadingOn Source

loadingOn :: forall f a. Tracked f => f a -> JSX -> JSX -> JSX

Like loading, but shows fallback again whenever key changes, e.g. the route's params, instead of keeping the previous content.

#errored Source

errored :: (Accessor Error -> Effect Unit -> Setup JSX) -> JSX -> JSX

The fallback receives the error and a reset effect (call it from an event handler) that retries.

#RevealOrder Source

newtype RevealOrder

Instances

#sequential Source

sequential :: RevealOrder

In order: each waits for the ones before it.

#together Source

together :: RevealOrder

All at once, when all are ready.

#natural Source

natural :: RevealOrder

Each as soon as it's ready.

#RevealOptions Source

type RevealOptions :: Row Typetype RevealOptions = (collapsed :: Boolean, order :: RevealOrder)

#reveal Source

reveal :: forall given missing. Union given missing RevealOptions => Record given -> Array JSX -> JSX

Coordinates the loading boundaries among children. Takes any subset of RevealOptions.

#portal Source

portal :: JSX -> JSX

Renders content into document.body (client only).

#portalAt Source

portalAt :: Element -> JSX -> JSX

Renders content into mount (client only).

#dynamic Source

dynamic :: forall f props. Tracked f => f (Component (Record props)) -> Record props -> JSX

#noHydration Source

noHydration :: JSX -> JSX

Server-rendered content that isn't hydrated.

#hydration Source

hydration :: JSX -> JSX

Re-enables hydration inside noHydration.

Re-exports from Solid.Internal.Identity

#StableIdentity Source

class StableIdentity a 

Values that stay === when a list is recomputed, so a list keyed by its items keeps each row: primitives and store cursors.

Instances