Update a nested field without mutating a private snapshot or unrelated data.
Real interfaces rarely consist only of counters. A profile contains nested fields, and a list contains records. A structured Signal keeps one owned root while projections provide typed writable views into that root.
Calling the structured root returns a private snapshot. Mutating that copy must not silently change live state. Without this boundary, an innocent-looking dictionary edit could bypass notification, validation and session ownership.
Understand the moving parts
Indexing a supported structured path creates a projection rather than freezing the current payload. Write through the projection or replace/update the root. For dataclasses, project accepts explicit getter/setter functions and can keep immutable replacement logic in one place.
In this lesson, editing the first score should not alter the second. The private copy experiment is intentionally visible: it changes the copy's readout while the live first-score readout stays put. This distinguishes real ownership from a demonstration that happens to print the expected initial value.
first and second project into the same owned root. Increment writes through first; Change a private copy edits the detached dictionary returned by profile() and displays 99 without writing the live scores.
Try it live
Increment the first score, then change a private copy. Compare first, second and the displayed copy before resetting.
What to observe
Only the first live score changes through its projection. The copy can show 99 without changing either live field.
First:
Second:
Private copy:
Take this with you
A projection writes through; a returned snapshot belongs to the caller.