persisting_state_of_components.md: Emphasize immutability and thread safety of SerializablePersistentStateComponent

This commit is contained in:
Karol Lewandowski 2025-03-13 10:07:04 +01:00
parent 22a9169b92
commit a01fb3b665

View File

@ -61,10 +61,10 @@ class MySettings : SimplePersistentStateComponent<MySettings.State>(State()) {
<chapter title="SerializablePersistentStateComponent" id="SerializablePersistentStateComponent"> <chapter title="SerializablePersistentStateComponent" id="SerializablePersistentStateComponent">
<primary-label ref="2022.2"/> <primary-label ref="2022.2"/>
[`SerializablePersistentStateComponent`](%gh-ic%/platform/projectModel-api/src/com/intellij/openapi/components/SerializablePersistentStateComponent.kt) is parameterized with a state data class. [`SerializablePersistentStateComponent`](%gh-ic%/platform/projectModel-api/src/com/intellij/openapi/components/SerializablePersistentStateComponent.kt) is parameterized with an immutable state data class.
State properties are exposed via persistent state component class' properties. State properties are exposed for reading and modification via persistent state component class' properties.
The state properties are modified by copying the state and overwriting a modified value within `SerializablePersistentStateComponent.updateState()`, which ensures atomic modification. The state properties are modified by copying the state and overwriting a modified value within `SerializablePersistentStateComponent.updateState()`, which ensures atomic modification and thread safety.
Example: Example: