Use Nested State

The Model currently has fields for different application concepts including view state, salad options, and contact information. This has produced an update function with too many responsibilities. You need modular patterns to manage the Model state so the application can scale. Otherwise, the update function will grow even more cumbersome over time.

In this section, you will use nested state to manage the salad portion of Model. You will modularize the application by creating a separate update function and message type for updating salad state. You will also learn the pros and cons of nested state.

Extract the Salad

One way to manage salad state is to create a Salad record type that has base, toppings, and dressing fields. Then, ...

Get Programming Elm now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.