Solid.Store
- Package
- purescript-purs-solid
- Repository
- arazorda/purs-solid
Stores: nested reactive state. Records and arrays are tracked per field and element; every other type is atomic, stored as-is and replaced as a whole.
Store.update setState $ Store.at (key @"todos") (Store.push todo)
#StoreSetter Source
data StoreSetter t0#StoreObject Source
class StoreObject a Instances
StoreObject (Record r)StoreObject (Array a)(Fail (Text "A store must hold a record or an array; wrap other values in a record")) => StoreObject a
#createStore Source
createStore :: forall m s. MonadReactive m => StoreObject s => StoreValue s => s -> m ((Store s) /\ (StoreSetter s))Works in Effect or Setup (stores need no owner). The initial value is
never mutated.
#Path Source
newtype Path s aA path to a field, built from record labels with key and composed with >>>.
Instances
#StoreCursor Source
class StoreCursor :: (Type -> Type) -> (Type -> Type) -> Constraintclass (Tracked f) <= StoreCursor store f | store -> f
Store and AsyncStore cursors, and what reading them gives: an
AsyncStore may not have its first value yet, so its values are Async.
Instances
#focus Source
focus :: forall store f s a. StoreCursor store f => Path s a -> store s -> store a#focusKey Source
focusKey :: forall @l store f r a tail. StoreCursor store f => IsSymbol l => Cons l a tail r => store (Record r) -> store afocusKey @"todos" store is focus (key @"todos") store.
#value Source
value :: forall store f a. StoreCursor store f => store a -> f aTracks the whole focused part; focus first to track less.
#items Source
items :: forall store f a. StoreCursor store f => StoreObject a => store (Array a) -> f (Array (store a))A cursor per element. Cursors keep their identity while an element stays in the array, so keyed list rendering reuses rows.
#update Source
update :: forall s. StoreSetter s -> Update s -> Effect UnitApplies an update. Readers see it after the next flush.
#set Source
set :: forall a. StoreValue a => a -> Update a#modify Source
modify :: forall a. StoreValue a => (a -> a) -> Update a#reconcile Source
reconcile :: forall a. StoreValue a => a -> Update aReplaces the value with next, keeping everything that didn't change
(and its readers). Array elements are matched by their id field.
#reconcileBy Source
reconcileBy :: forall a k. StoreValue a => (a -> k) -> Array a -> Update (Array a)reconcile for an array, matching elements by a key function. Keys are
compared with ===, so use primitives.
#reconcileByPosition Source
reconcileByPosition :: forall a. StoreValue a => Array a -> Update (Array a)reconcile for an array, matching elements by position.
#createProjection Source
createProjection :: forall s. StoreObject s => StoreValue s => Accessor (Update s) -> s -> Setup (Store s)A read-only store derived from reactive sources: compute is tracked and
yields the update to apply whenever its dependencies change.
#createProjectionAsync Source
createProjectionAsync :: forall s. StoreObject s => StoreValue s => Accessor (Aff (Update s)) -> s -> Setup ((AsyncStore s) /\ (Refresh s))Like createProjection, but the update comes from async work: readers
suspend (show loading fallbacks) until the first update, and a change of
compute's dependencies kills the running Aff. Refresh re-runs it.
#createDerivedStore Source
createDerivedStore :: forall s. StoreObject s => StoreValue s => Accessor (Update s) -> s -> Setup ((Store s) /\ (StoreSetter s))A store derived like createProjection that can also be updated locally;
a local update holds until compute's dependencies change.
#OptimisticStore Source
data OptimisticStore t0Updated only from a Solid.Action.Action; its updates show immediately
and revert when the action settles.
#createOptimisticStore Source
createOptimisticStore :: forall m s. MonadReactive m => StoreObject s => StoreValue s => s -> m ((Store s) /\ (OptimisticStore s))A store whose updates are tentative: made during an action, reverted when it settles.
#createOptimisticProjection Source
createOptimisticProjection :: forall s. StoreObject s => StoreValue s => Accessor (Update s) -> s -> Setup ((Store s) /\ (OptimisticStore s))Follows compute like createProjection, with tentative updates layered
on top during actions.
#updateOptimistic Source
updateOptimistic :: forall m s. MonadOptimistic m => OptimisticStore s -> Update s -> m UnitA tentative update, as a step of a Solid.Action.Action.
#affects Source
affects :: forall m store f s. MonadOptimistic m => StoreCursor store f => StoreObject s => store s -> m UnitMarks the focused part of a store as pending until the action settles.
Re-exports from Solid.Internal.Optimistic
#MonadOptimistic Source
class MonadOptimistic :: (Type -> Type) -> Constraintclass (Monad m) <= MonadOptimistic m
Re-exports from Solid.Internal.Store
#AsyncStore Source
data AsyncStore t0A cursor into a store that may not have its first value yet (an async
projection): reading it gives Async values.
#StoreFields Source
class StoreFields :: RowList Type -> Constraintclass StoreFields rl
Instances
StoreFields Nil(IsSymbol l, StoreValue a, StoreFields tail) => StoreFields (Cons l a tail)
#StoreValue Source
class StoreValue a How a type is stored: records and arrays are tracked per field / element;
anything else is atomic. Every type has an instance. preparer is a value,
so it's built once per type.
Instances
StoreValue IntStoreValue NumberStoreValue StringStoreValue BooleanStoreValue Char(RowToList r rl, StoreFields rl) => StoreValue (Record r)(StoreValue a) => StoreValue (Array a)StoreValue a
- Modules
- Solid.
Action - Solid.
Async - Solid.
Component - Solid.
Component. JS - Solid.
Context - Solid.
Control - Solid.
DOM - Solid.
DOM. Aria - Solid.
DOM. AttrValue - Solid.
DOM. HTML - Solid.
DOM. SVG - Solid.
Errors - Solid.
Internal. Action - Solid.
Internal. Equality - Solid.
Internal. Identity - Solid.
Internal. Names - Solid.
Internal. Optimistic - Solid.
Internal. Props - Solid.
Internal. Reply - Solid.
Internal. Serializable - Solid.
Internal. ServerFunction - Solid.
Internal. Setup - Solid.
Internal. Store - Solid.
Internal. Tracked - Solid.
Internal. View - Solid.
JSX - Solid.
Lifecycle - Solid.
Meta - Solid.
Owner - Solid.
Reactivity - Solid.
Root - Solid.
Router - Solid.
Router. Action - Solid.
Router. Path - Solid.
Router. Query - Solid.
Router. Search - Solid.
Setup - Solid.
Signal - Solid.
Start. Middleware - Solid.
Start. RequestEvent - Solid.
Start. Response - Solid.
Start. ServerFunction - Solid.
Start. UseServer - Solid.
Store - Solid.
Testing - Solid.
Utility - Solid.
Web - Solid.
Web. SSR