Radox
- Package
- purescript-radox
- Repository
- danieljharvey/purescript-radox
Re-exports from Radox.Internal.CreateStore
#emptyStore Source
emptyStore :: forall actionType stateType. stateType -> RadoxStore actionType stateTypeThings like React Context require us to provide a starting value, this allows us to pass one without using Effect.
#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
Re-exports from Radox.Internal.Store
#update Source
update :: forall actionType stateType. Ref stateType -> Listeners stateType -> Effect stateType -> CombinedReducer actionType stateType -> actionType -> Effect UnitThis takes our action runs it through the reducers, updates listeners with the result
And then updates the ref with the new value
Note actionType must have have been lift-ed into the Variant for use here
Re-exports from Radox.Internal.Types
#ReducerReturn Source
data ReducerReturn stateTypeType of return value from reducer
Constructors
NoOpUpdateState stateTypeUpdateStateAndRunEffect stateType (Aff Unit)RunEffect (Aff Unit)
#Reducer Source
type Reducer actionType stateType = actionType -> stateType -> stateTypeType for a reducer that does need to trigger any side effects
#RadoxStore Source
type RadoxStore combinedActionType stateType = { dispatch :: Dispatcher combinedActionType, getState :: Effect stateType, state :: stateType }Type of store shared around so that the state can be accessed without needing Effect
#RadoxEffects Source
type RadoxEffects combinedActionType stateType = { dispatch :: combinedActionType -> Effect Unit, getState :: Effect stateType, state :: stateType }#EffectfulReducer Source
type EffectfulReducer actionType stateType combinedActionType = RadoxEffects combinedActionType stateType -> actionType -> stateType -> ReducerReturn stateTypeType for any user-created Reducer function that takes an Action for a specific reducer, the entire state, and returns a new copy of the state
#Dispatcher Source
type Dispatcher combinedActionType = combinedActionType -> Effect UnitA Dispatcher is the function that allows different parts of our app to send actions to the reducers and make Things Happen.
#CombinedReducer Source
type CombinedReducer combinedActionType stateType = RadoxEffects combinedActionType stateType -> stateType -> combinedActionType -> ReducerReturn stateTypeType for the user-created Combined Reducer function, that takes a Variant of any action, and pipes it to the correct Reducer function, then returns the new state