martmists
09/17/2025, 3:46 PMZach Klippenstein (he/him) [MOD]
09/17/2025, 5:21 PMSaveableStateRegistry to save its providers and serializing those values (also using some Android-specific features). I would think most desktop environments would have a hook for that too, although idk how or even if that's exposed through Java.martmists
09/17/2025, 6:25 PMZach Klippenstein (he/him) [MOD]
09/17/2025, 6:40 PMmartmists
09/17/2025, 11:43 PMclass SudokuState(
val solvedBoard: IntArray,
val revealed: BooleanArray
) {
val userAnswers = SnapshotStateList(solvedBoard.size) { if (revealed[it]) solvedBoard[it] else -1 } // -1 = empty
var solved by mutableStateOf(false)
fun set(i: Int, newValue: Int) {
userAnswers[i] = newValue
solved = solvedBoard.toList().zip(userAnswers).all { (a, b) -> a == b }
}
}
@Composable
fun Sudoku(state: SudokuState) {
// ...
SudokuSlot(state.userAnswers[i]) { newValue ->
state.set(i, newValue)
}
}
How/where would I implement saving/loading to a SavableStateRegistry? especially if multiple SudokuStates may exist at any given timeZach Klippenstein (he/him) [MOD]
09/18/2025, 12:10 AMval state = rememberSaveable(saver = SudokuState.Saver(solvedBoard, revealed)) { SudokuState(solvedBoard, revealed) }Zach Klippenstein (he/him) [MOD]
09/18/2025, 12:11 AMclass SudokuState(…) {
class Saver(
val solvedBoard: IntArray,
val revealed: BooleanArray
) : androidx.compose.runtime.Saver<SudokuState, Something> {
// implement save/restore
}
}martmists
09/18/2025, 12:27 PMclass FakeDesktopState {
val windows = snapshotStateListOf<FakeWindow>()
}
class FakeWindow {
val handle: AppInstance<*>
}
class AppInstance<T> {
val app: App<T>
val state: T
}
class SudokuApp : App<SudokuState>
// Editing the SudokuState here should also make sure the FakeDesktopState saves downwards, because the SudokuState cares about the window it's in, and windows may switch positions in the list (but the states switch along with them, and I believe rememberSavable cares about the current index in the composable tree?)Zach Klippenstein (he/him) [MOD]
09/18/2025, 12:53 PMmartmists
09/18/2025, 4:38 PMWrite pluggable components that save the UI state when a process diesThat doesn't sound like it'd work on web 😕
Zach Klippenstein (he/him) [MOD]
09/18/2025, 4:39 PMZach Klippenstein (he/him) [MOD]
09/18/2025, 4:39 PMmartmists
09/18/2025, 4:42 PMZach Klippenstein (he/him) [MOD]
09/18/2025, 4:45 PM