I’m trying to make the transition from Browser.element to Browser.application, but I’m struggling to get started.
- In the Guide under Structuring Web Apps it says, “I would have a module for each page, centered around the Model type. Those modules follow The Elm Architecture with the typical
Model,init,update,view, and whatever helper functions you need.”
A Model in each module? Does this not conflict with the idea of keeping all state in one place?
In Main.elm we tie the main functions together in a record in a Browser.* function. What would tie them together in a (sub-)module?
- Under Navigation it says, " When someone clicks a link, like
<a href="/home">Home</a>, it is intercepted as aUrlRequest. So instead of loading new HTML with all the downsides,onUrlRequestcreates a message for yourupdatewhere you can decide exactly what to do next."
But my Browser.element app doesn’t have any links. All of my ‘links’ are of the form onClick or onPress which generate messages, sometimes leading to an new view. How, and where, should I replace them?
- The Document type
type alias Document msg =
{ title : String
, body : List (Html msg)
}
Why does body have the type List (Html msg) and not just simply Html msg?
How should we handle this? There is the obvious [header, main, footer] structure, but there must be a more fundamental reason why it’s a list.
- I have tried looking through Richard Feldman’s Elm spa Example, but it’s very complex.
Among other things, it makes extensive use of Html.map. But the documentation for Html.map says, “This should not come in handy too often. Definitely read this before deciding if this is what you want.”
(ps this is a broken link).
And the let section of the top level view function has my head spinning.