Lilly
02/19/2021, 7:49 PMrememberSaveable
but it doesn't get restored, instead it jumps always into the init method of rememberSaveable
. What am I doing wrong?
val navigator: Navigator<T> by rememberSaveable(
stateSaver = Navigator.saver(backDispatcher = backDispatcher),
key = "State
) {
println("initial")
mutableStateOf(
Navigator(
initialConfiguration = initialConfiguration,
backDispatcher = backDispatcher
)
)
}
fun <T : Parcelable> saver(
backDispatcher: OnBackPressedDispatcher
) = listSaver<Navigator<T>, T>(
save = { navigator -> navigator.backStack.toList() },
restore = { backStack -> Navigator(backStack, backDispatcher) }
)
I noticed that rememberSaveable
is called internally multiple times, first time with my provided key and the other times it jumps into the else branch and generates a hash. Is this a bug?
rememberSaveable:
val finalKey = if (!key.isNullOrEmpty()) {
key
} else {
currentCompositeKeyHash().toString()
}
Andrey Kulikov
02/19/2021, 9:51 PMLilly
02/19/2021, 10:13 PMAndrey Kulikov
02/19/2021, 10:33 PMAndrey Kulikov
02/19/2021, 10:33 PMval navigator: Navigator<T> = rememberSaveable(
saver = Navigator.saver(backDispatcher = backDispatcher),
key = "State"
) {
Navigator(
initialConfiguration = initialConfiguration,
backDispatcher = backDispatcher
)
}
Andrey Kulikov
02/19/2021, 10:34 PMLilly
02/19/2021, 11:35 PM