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 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.