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

#ReadOnlyRedox Source

type ReadOnlyRedox eff = (readRedox :: ReadRedox | eff)

#WriteOnlyRedox Source

type WriteOnlyRedox eff = (writeRedox :: WriteRedox | eff)

#ReadWriteRedox Source

type ReadWriteRedox eff = (readRedox :: ReadRedox, writeRedox :: WriteRedox | eff)

#ReadWriteSubscribeRedox Source

type ReadWriteSubscribeRedox eff = (readRedox :: ReadRedox, subscribeRedox :: SubscribeRedox, writeRedox :: WriteRedox | eff)

#Store Source

data Store :: Type -> Type

Instances

#mkStore Source

mkStore :: forall eff state. state -> Eff (createRedox :: CreateRedox | eff) (Store state)

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

#subscribe Source

subscribe :: forall eff state. Store state -> (state -> Eff (subscribeRedox :: SubscribeRedox | eff) Unit) -> Eff (subscribeRedox :: SubscribeRedox | 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 state. Store state -> SubscriptionId -> Eff (subscribeRedox :: SubscribeRedox | eff) Unit

Remove a subscription with a given id.

#mapStore Source

mapStore :: forall eff state' state. (state -> state') -> Store state -> Eff (ReadWriteRedox eff) (Store state')

#setState Source

setState :: forall eff state. Store state -> state -> Eff (WriteOnlyRedox eff) (Store state)

#getState Source

getState :: forall eff state. Store state -> Eff (ReadOnlyRedox eff) state

#getSubs Source

getSubs :: forall eff state. Store state -> Eff (readRedox :: ReadRedox | eff) (Array (state -> Eff (readRedox :: ReadRedox | eff) Unit))

Get subscriptions.

#performCreateRedoxEff Source

performCreateRedoxEff :: forall a. Eff (createRedox :: CreateRedox) a -> a

#performWriteRedoxEff Source

performWriteRedoxEff :: forall a. Eff (WriteOnlyRedox ()) a -> a

#performReadRedoxEff Source

performReadRedoxEff :: forall a. Eff (ReadOnlyRedox ()) a -> a

#performReadWriteRedoxEff Source

#mkStoreG Source

mkStoreG :: forall state. state -> Store state

Make store outside of Eff monad (global).