Module

Oak

Package
purescript-oak
Repository
ehrenmurdick/purescript-oak

#App Source

data App msg model

#createApp Source

createApp :: forall model msg. { init :: model, next :: msg -> model -> (msg -> Effect Unit) -> Effect Unit, update :: msg -> model -> model, view :: model -> Html msg } -> App msg model

createApp takes a record with a description of your Oak app. It has a few parts:

init:

the inital model state.

view:

Maps the current model to an html view.

next:

This function maps a message and model to a command. For example, for sending an Http request when a user clicks a button. next would be called with the button click message and would return an Oak.Cmd that will execute the request.

update:

Takes an incoming message, and the previous model state, and returns the new model state.

#unwrapApp Source

unwrapApp :: forall model msg. App msg model -> { init :: model, next :: msg -> model -> (msg -> Effect Unit) -> Effect Unit, update :: msg -> model -> model, view :: model -> Html msg }

#runApp Source

runApp :: forall model msg. App msg model -> Maybe msg -> Effect Node

Kicks off the running app, and returns an effect containing the root node of the app, which can be used to embed the application. See the main function of the example app in the readme.