min
02/27/2026, 12:49 PMPreexistingSnapshotId
Copy codeconst val PreexistingSnapshotId = 1: Int
All new state objects initial state records should beI don’t understand this explanation in the docs. Could anybody please help me make sense of it? Why is itwhich then allows snapshots outside the creating snapshot to access the object with its initial state.PreexistingSnapshotId
1, and how does it achieve its objective?shikasd
03/01/2026, 1:04 PMChuck Jazdzewski [G]
03/04/2026, 7:31 PMval foo =mutableStateOf(27) it assume to have always have existed with the value 27, the snapshot is just seeing it now. This is implemented by reserving a snapshot ID to hold the initial value of a mutable state, which is what PreexsitingSnasphotId is.
This rather subtle change we made allows state to be created in a snapshot that escapes the snapshot and still valid to read or update even before the snapshot that created it applies. This can be used by background threads and background coroutines to perform optimistic work in anticipation of a composition successfully landing (e.g. loading a bitmap).