Module

Radox.Internal.CreateStore

Package
purescript-radox
Repository
danieljharvey/purescript-radox

#createStore Source

createStore :: forall actionType stateType. stateType -> Listeners stateType -> CombinedReducer actionType stateType -> Effect (RadoxStore actionType stateType)

This creates a new Radox store

initialState is how our state looks when we start

listeners are an array of stateType -> Effect Unit functions that will be sent the new state everything it is updated

'rootReduceris the function that takes ouractionTypeand astateTypeand returns the newstateType`

This returns a RadoxStore, which has a dispatch function for sending new actions and a getState function

#lift Source

lift :: forall r dunno action label. Cons label action dunno r => HasLabel action label => IsSymbol label => action -> Variant r

When we dispatch an action, we need to first lift it into our main Variant type Thus, to dispatch an Up action we'd do dispatch (lift Up)

#emptyStore Source

emptyStore :: forall actionType stateType. stateType -> RadoxStore actionType stateType

Things like React Context require us to provide a starting value, this allows us to pass one without using Effect.