This module contains pipeline functions that can be helpful when setting up an Elm program for initial testing and adding features as you go.
Construct a static program with just setup and run to test your initial
model and view. Then add interaction with update. Add Dom effects, HTTP
requests, and so on with onLoad and updateWithCmds. Add ports with
subscribe or subscribeWithParams. Use runWithFlags to pass data to your
initial model.
The Dom.Program.run function is an alias for VirtualDom.program, so just use
that if you want to set up a program in the standard way.
Route messages generated in the program to a function that will update the initial model; the first argument is the update function, and the second argument is the setup record
main =
initialModel
|> Dom.Program.setup view
|> Dom.Program.update update
|> Dom.Program.runTell the Elm compiler to generate a program from your setup
Alias for VirtualDom.program
Modify your program setup to perform a list of commands when the program loads
main =
initialModel
|> Dom.Program.setup view
|> Dom.Program.onLoad
[ doSomething
, doSomethingElse
]
|> Dom.Program.update update
|> Dom.Program.runSee the Elm Architecture documentation to find out more about commands.
Handle updates in a with a function that can also produce commands in response to messages
initialModel
|> Dom.Program.setup view
|> Dom.Program.updateWithCmds update
|> Dom.Program.runSee the Elm Architecture documentation to find out more about commands.
Receive data from ports
initialModel
|> Dom.Program.setup view
|> Dom.Program.updateWithCmds update
|> Dom.Program.subscribe
[ listener1
, listener2
]
|> Dom.Program.runSee the Elm Architecture documentation to find out more about ports and subscriptions.
Apply a custom function to control data flow from ports
initialModel
|> Dom.Program.setup view
|> Dom.Program.updateWithCmds update
|> Dom.Program.subscribeWithParams subscribe
|> Dom.Program.runSee the Elm Architecture documentation to find out more about ports and subscriptions.
Generate your initial model with data passed to your Elm program from the JavaScript side, with the initial model specified in your setup as a fallback if anything goes wrong
defaultSettings
|> initializer
|> Dom.Program.setup view
|> Dom.Program.updateWithCmds update
|> Dom.Program.subscribeWithParams subscribe
|> Dom.Program.runWithFlags initializerSee the Elm Architecture documentation to find out more about flags.
Alias for VirtualDom.programWithFlags
Type alias for arguments to VirtualDom.program
Generate a record that describes the setup of an Elm program; the first argument is a function that takes a model and generates a view, and the second argument is an initial model to pass to that function
These two function calls will setup and run a static program (a program where the view doesn't update):