Module

Redox.Store

Package
purescript-redox
Repository
coot/purescript-redox

#CreateRedox Source

data CreateRedox :: Effect

Effect for creating Redox Store

#ReadRedox Source

data ReadRedox :: Effect

Effect for reading state of the store or retreaving store subscribers.

#WriteRedox Source

data WriteRedox :: Effect

Effect for writing to the store

#SubscribeRedox Source

data SubscribeRedox :: Effect

Effect for (un)subscribing to the store

#RedoxStore Source

#ReadOnlyRedox Source

type ReadOnlyRedox = (read :: ReadRedox)

#WriteOnlyRedox Source

type WriteOnlyRedox = (write :: WriteRedox)

#ReadWriteRedox Source

type ReadWriteRedox = (read :: ReadRedox, write :: WriteRedox)

#ReadWriteSubscribeRedox Source

type ReadWriteSubscribeRedox = (read :: ReadRedox, subscribe :: SubscribeRedox, write :: WriteRedox)

#CreateReadWriteSubscribeRedox Source

type CreateReadWriteSubscribeRedox = (create :: CreateRedox, read :: ReadRedox, subscribe :: SubscribeRedox, write :: WriteRedox)

#Store Source

data Store :: Type -> Type

#mkStore Source

mkStore :: forall eff e state. state -> Eff (redox :: RedoxStore (create :: CreateRedox | e) | eff) (Store state)

Make store with initial state. Store is a mutable container with a subscription mechanism.

#subscribe Source

subscribe :: forall eff' eff e state. Store state -> (state -> Eff eff' Unit) -> Eff (redox :: RedoxStore (subscribe :: SubscribeRedox | e) | eff) SubscriptionId

Subscribe to store updates. Note that store updates are not run by the store itself. That is left to dispatch or the DSL interpreter. It returns id of the subscribed callback. You can use it to remove the subscription.

#unsubscribe Source

unsubscribe :: forall eff e state. Store state -> SubscriptionId -> Eff (redox :: RedoxStore (subscribe :: SubscribeRedox | e) | eff) Unit

Remove a subscription with a given id.

#modifyStore Source

modifyStore :: forall eff e state' state. (state -> state') -> Store state -> Eff (redox :: RedoxStore (read :: ReadRedox, write :: WriteRedox | e) | eff) (Store state')

#setState Source

setState :: forall eff e state. Store state -> state -> Eff (redox :: RedoxStore (write :: WriteRedox | e) | eff) (Store state)

#getState Source

getState :: forall eff e state. Store state -> Eff (redox :: RedoxStore (read :: ReadRedox | e) | eff) state

#getSubscriptions Source

getSubscriptions :: forall eff e state. Store state -> Eff (redox :: RedoxStore (read :: ReadRedox | e) | eff) (Array (state -> Eff (redox :: RedoxStore (read :: ReadRedox | e) | eff) Unit))

Get subscriptions.

#performRedoxEff Source

performRedoxEff :: forall e a. Eff (redox :: RedoxStore e) a -> a

#mkStoreG Source

mkStoreG :: forall state. state -> Store state

Make store outside of Eff monad (global).