Ya, I am aware of those short comings, I mentioned some of them here but never got a response: Serializable PersistentStateComponent docs look to be wrong
We have been using the class for about a year now which is why I have my data classes defined in the form of:
data class State(
@field:Property val a: Boolean = true,
@field:Property val b: String? = null,
@field:Property val c: String? = null
)
Why do you need to track the disk loading specifically?
I don’t per se, but loadState is the only way to load the saved settings into a StateFlow, our code looks nearly verbatim to GitLabPersistentAccounts.kt, but with more fields
var a: String?
get() = state.a
set(value) {
updateStateAndEmit {
it.copy(a = value)
}
}
private fun updateStateAndEmit(updateFunction: (currentState: State) -> State) {
updateState(updateFunction)
stateFlow.value = state
}
override fun loadState(state: State) {
super.loadState(state)
stateFlow.value = state
}