Module

Solid.Signal

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

Signals: the writable sources of the reactive graph. map / do on an Accessor build derived accessors that recompute when read (cache them with Solid.Reactivity.createMemo). Writes are batched until the next flush. Values that may not have loaded yet are Async instead, and can't be read directly.

#Setter Source

data Setter t0

#toAsync Source

toAsync :: forall a. Accessor a -> Async a

An Async from a value that is always ready, e.g. to combine it with async values in a do block.

#Signal Source

type Signal a = (Accessor a) /\ (Setter a)

#SignalOptions Source

type SignalOptions :: Type -> Row Typetype SignalOptions a = (equals :: Equality a, name :: String, ownedWrite :: Boolean, unobserved :: Effect Unit)

#createSignal Source

createSignal :: forall m a. MonadReactive m => a -> m (Signal a)

Works in Effect or Setup; signals need no disposal.

#createSignalWith Source

createSignalWith :: forall m a given missing. MonadReactive m => Union given missing (SignalOptions a) => Record given -> a -> m (Signal a)

Takes any subset of SignalOptions.

#get Source

get :: forall a. Accessor a -> Effect a

Reads the current value without subscribing. An Async value can't be read this way; Solid.Async.resolve waits for it.

#sample Source

sample :: forall a. Accessor a -> Setup a

Reads the current value during setup without tracking. For initial values; pass the Accessor on for anything that should stay reactive.

#untrack Source

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

Reads value without subscribing the computation reading it.

#set Source

set :: forall a. Setter a -> a -> Effect Unit

Writes a value. Visible to reads after the next flush.

#modify Source

modify :: forall a. Setter a -> (a -> a) -> Effect a

Updates the value from its latest (possibly not yet flushed) value and returns the value written.

#modify_ Source

modify_ :: forall a. Setter a -> (a -> a) -> Effect Unit

Re-exports from Solid.Internal.Equality

#Equality Source

data Equality t0

When a new value counts as a change: Solid's equals option. Leaving it out means reference equality (===), so a freshly built record or array always counts as a change.

#eqEquality Source

eqEquality :: forall a. Eq a => Equality a

Structural equality via Eq: rebuilding an equal value doesn't notify.

#customEquals Source

customEquals :: forall a. (a -> a -> Boolean) -> Equality a

true means "equal, don't notify".

#alwaysNotify Source

alwaysNotify :: forall a. Equality a

Every write notifies, even of the same value.

Re-exports from Solid.Internal.Tracked

#Async Source

data Async t0

A reactive value that may not have loaded yet. It can't be read directly (get, sample): render it, derive from it, or wait for it with Solid.Async.resolve.

Instances

#Accessor Source

data Accessor t0

A reactive value: read inside a tracked computation, it subscribes it.

Instances

#Tracked Source

class Tracked :: (Type -> Type) -> Constraintclass (Monad f) <= Tracked f 

Accessor and Async: what tracked computations, bindings and control flow read.

Instances