Handle State Changes
In MVC and MVVM applications, you can mutate models from almost anywhere in the codebase. This leads to the problem of not knowing where or when state changes. The Elm Architecture solves this with its update process. Just as all state is located in the model, all changes to the model have to take place in an update function.
The update function takes two arguments, a message and the model. The message argument comes from Elm’s runtime in response to events such as mouse clicks, server responses, and WebSocket events. The message describes the type of state change. We’ll discuss messages in the next section and the Elm runtime in more detail in a later section.
The update function is responsible for interpreting the message ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access