Skip to main content

Immutable updates, normalization, derived, loading and error state

Learn Immutable updates, normalization, derived, loading and error state (Module 15 · State Management, Angular) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Four habits of clean state • Immutable state updates : never change an object in place; create a new one. Change detection and signals notice new references only. • Derived state : do not store what can be calculated (the total of a cart); compute it. • State normalization : store each item once, by id, and refer to it by id. Like a database: a foreign key instead of copying the whole row. • Loading and error states : every remote request has phases: idle, loading, success, error. Model them explicitly so the UI can show spinners and messages.

More lessons in Module 15 · State Management