Module
Bonsai.Core
- Package
- purescript-bonsai
- Repository
- grmble/purescript-bonsai
#Program Source
type Program model msg = { dbgEvents :: Boolean, dbgTiming :: Boolean, pending :: Ref (Array msg), renderer :: model -> VNode msg, state :: Ref (ProgramState model msg), updater :: model -> msg -> UpdateResult model msg }
Program describes the Bonsai program.
It is passed around in a ReaderT and stores callbacks and a ref to the pending commands. Event callbacks append to the list of pending commands, they will then be applied in the main event loop.
#UpdateResult Source
type UpdateResult model msg = { cmd :: Cmd msg, model :: model }
An update functions returns a new model and a possibly empty command
#plainResult Source
plainResult :: forall msg model. model -> UpdateResult model msg
Creates an update result with empty command.
#mapResult Source
mapResult :: forall msg2 model2 msg1 model1. (model1 -> model2) -> (msg1 -> msg2) -> UpdateResult model1 msg1 -> UpdateResult model2 msg2
Helper to map update results from sub-components
#ProgramState Source
type ProgramState model msg = { dnode :: Element, model :: model, vnode :: VNode msg }
ProgramState tracks the current state of the model, vnode and dom element.
These are needed to advance the state in reaction to a Cmd message.