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