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 ...
Get Programming Elm now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.