Module

Solid.Async

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

Async values in the reactive graph. In createAsync, read dependencies in the tracked Accessor layer; the Aff is untracked and is killed when a dependency changes. Values load on the client unless ssr is serialized or withCodec.

#AsyncOptions Source

type AsyncOptions :: Type -> Row Typetype AsyncOptions a = (deferStream :: Boolean, equals :: Equality a, lazy :: Boolean, loadingValue :: a, name :: String, ssr :: AsyncSsr a, unobserved :: Effect Unit)

#AsyncSsr Source

newtype AsyncSsr a

Where an async value loads when the page is server-rendered.

#onClient Source

onClient :: forall a. AsyncSsr a

Load on the client; the server renders the loading fallback.

#serialized Source

serialized :: forall a. Serializable a => AsyncSsr a

Load on the server and send the value with the page.

#withCodec Source

withCodec :: forall a. (a -> Json) -> (Json -> Either String a) -> AsyncSsr a

Load on the server and send the value encoded as JSON.

#createAsync Source

createAsync :: forall a. Accessor (Aff a) -> Setup ((Async a) /\ (Refresh a))

The value is Async: it can't be read before it has loaded, only rendered (under a loading boundary), derived from, or waited for with resolve.

#createAsyncWith Source

createAsyncWith :: forall f a given missing. Union given missing (AsyncOptions a) => AsyncResult given f => Record given -> Accessor (Aff a) -> Setup ((f a) /\ (Refresh a))

Takes any subset of AsyncOptions. With a loadingValue there is always a value to read, so the result is an Accessor.

#createAsyncFrom Source

createAsyncFrom :: forall a. Async (Aff a) -> Setup ((Async a) /\ (Refresh a))

createAsync whose work depends on other async values; it waits for them.

#createAsyncFromWith Source

createAsyncFromWith :: forall f a given missing. Union given missing (AsyncOptions a) => AsyncResult given f => Record given -> Async (Aff a) -> Setup ((f a) /\ (Refresh a))

Takes any subset of AsyncOptions, like createAsyncWith.

#AsyncResult Source

class AsyncResult :: Row Type -> (Type -> Type) -> Constraintclass (Tracked f) <= AsyncResult given f | given -> f

Accessor when the options have a loadingValue, Async otherwise.

Instances

#AsyncResultList Source

class AsyncResultList :: RowList Type -> (Type -> Type) -> Constraintclass (Tracked f) <= AsyncResultList list f | list -> f

Instances

#Refresh Source

data Refresh t0

Re-runs one async value's work even though its inputs haven't changed.

#refresh Source

refresh :: forall a. Refresh a -> Effect Unit

Re-runs the async work in the background.

#refreshAff Source

refreshAff :: forall a. Refresh a -> Aff a

Re-runs the async work and waits until the graph settles with the new value.

#isPending Source

isPending :: forall f a. Tracked f => f a -> Accessor Boolean

true while a change to accessor's value is in flight. Not true for the first load (that's what loading boundaries are for), nor for a bare refresh.

#latest Source

latest :: forall f a. Tracked f => f a -> f a

The in-flight value where one exists, instead of the settled one.

#resolve Source

resolve :: forall f a. Tracked f => f a -> Aff a

Waits for value to settle and returns it.

#UntilOptions Source

type UntilOptions :: Row Typetype UntilOptions = (timeout :: Milliseconds)

#until Source

until :: forall f a. Tracked f => f (Maybe a) -> Aff a

Waits until predicate is Just, re-checking as its sources change. Reads see settled state, so an optimistic write can't satisfy it. Killing the fiber stops waiting.

#untilWith Source

untilWith :: forall f a given missing. Tracked f => Union given missing UntilOptions => Record given -> f (Maybe a) -> Aff a

Takes any subset of UntilOptions.

Re-exports from Solid.Internal.Serializable

#Serializable Source

class Serializable a 

Types that survive Solid's serialization unchanged: primitives, Unit, Nullable, Json, arrays, objects and records of them. A newtype over one can derive it (derive newtype instance Serializable UserId). ADTs lose their constructors, so they need an explicit codec.

Instances