Module

Oak

Package
purescript-oak
Repository
ehrenmurdick/purescript-oak

#App Source

data App c model msg flags

#createApp Source

createApp :: forall msg model c flags. { init :: flags -> model, update :: msg -> model -> model, next :: msg -> model -> Cmd c msg, view :: model -> Html msg } -> App c 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 c e model msg flags. App c model msg flags -> flags -> Eff (dom :: DOM | e) 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.