Module
Marionette.Controllers.ControlAPI
- Package
- purescript-marionette
- Repository
- thought2/purescript-marionette
A Control handler that runs in Aff and provides a beginner friendly API
to handle state updates with effects.
#Control Source
type Control msg sta = ControlAPI msg sta -> msg -> Aff UnitThe high level control function. Takes an interface to a control API
and a msg and returns an effectful computation inside Aff.
#ControlAPI Source
type ControlAPI msg sta = { getState :: Aff sta, modifyState :: (sta -> sta) -> Aff sta, modifyState_ :: (sta -> sta) -> Aff Unit, putState :: sta -> Aff Unit, sendMsg :: msg -> Aff Unit }Provides read/write access to the current state and a way to raise new messages at any time in the control handler
sendMsgRaise a new message.getStateSet the current state.putStateSet the state.modifyStateModify the state by applying a function to the current state. The returned value is the new state value.modifyState_Modify the state by applying a function to the current state.
#mkController Source
mkController :: forall msg sta. Control msg sta -> Controller msg staCreates a low level controller when given a high level control function