Module

Toestand

Package
purescript-toestand
Repository
garganscript/purescript-toestand

A simple way of managing a tree of state in react while retaining full control over rerendering.

Re-exports from Toestand.Boxes

#Box Source

data Box b

Instances

#useLive Source

useLive :: forall box b. Read box b => ShouldReload b -> box -> Hooks b

Return the live value of the box. Reload the current component when it is updated if the provided effectful callback returns true

#useFocused Source

useFocused :: forall box b c. ReadWrite box b => (b -> c) -> (c -> b -> b) -> box -> Hooks (Box c)

Create a new box by focusing in on the box with accessor functions.

#useBox Source

useBox :: forall b. b -> Hooks (Box b)

A hook which allocates a Box, a flexible mutable wrapper for state utilising a react ref

Re-exports from Toestand.Changes

#ShouldReload Source

type ShouldReload c = Change c -> Effect Boolean

An effect function which determines whether notifications should be sent.

#Listener Source

type Listener c = Change c -> Effect Unit

An Effect function which is provided the new and old values.

#Change Source

type Change c = { new :: c, old :: c }

A summary of a change in value

#unequal Source

unequal :: forall v. Eq v => Change v -> Effect Boolean

An equality based refresh predicate

#unchanged Source

unchanged :: forall a b. (Change a -> b) -> a -> a -> b

Adapt a change function to a positional function. new first.

#mapChange Source

mapChange :: forall c d. (c -> d) -> Change c -> Change d

Transform a Change by applying a function to both old and new values.

#changed Source

changed :: forall a b. (a -> a -> b) -> Change a -> b

Adapt a positional function to a change function. new first.

#change Source

change :: forall a. a -> a -> Change a

Create a change positionally. new first.

Re-exports from Toestand.Classes

#Read Source

class Read box val | box -> val where

A Box-like container that can be read from

Members

#ReadWrite Source

class (Read box val, Write box val) <= ReadWrite box val | box -> val

A shorter way of specify Read+Write

Instances

#Write Source

class Write box val | box -> val where

A Box-like container that can be written to.

Members

  • write :: val -> box -> Effect val

    Write a new value into the box.

#write_ Source

write_ :: forall box v. Write box v => v -> box -> Effect Unit

Unit-returning version of write

#modify_ Source

modify_ :: forall box v. ReadWrite box v => (v -> v) -> box -> Effect Unit

Change the value in a Box by applying a function to it.

#modify Source

modify :: forall c v. ReadWrite c v => (v -> v) -> c -> Effect v

Change the value in a Box by applying a function to it.

Re-exports from Toestand.Records

#useFocusedFields' Source

useFocusedFields' :: forall l out base box c. RowToList c l => ReadWrite box (Record c) => UseFocusedFields l out base box => box -> Hooks (Builder (Record base) (Record out))

Builder-returning variant of useFocusedFields

#useFocusedFields Source

useFocusedFields :: forall l out base box c. RowToList c l => ReadWrite box (Record c) => UseFocusedFields l out base box => box -> Record base -> Hooks (Record out)

Given a Box (or other ReadWrite) which points at a record, create a new record where each field is another Box focused over the corresponding field in the original record.