Module

Oak

Package
purescript-oak
Repository
ehrenmurdick/purescript-oak

#App Source

data App model msg flags

#createApp Source

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

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

init:

A function from you flags type to the inital model state. Flags type can be Unit if you don't need this for anything.

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.

#runApp Source

runApp :: forall flags msg model. App model msg flags -> flags -> 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.