Redesign PlaylistScreen (#172)
This commit is contained in:
@@ -51,6 +51,30 @@ fun <T> produceSaveableState(
|
||||
return state
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> produceSaveableOneShotState(
|
||||
initialValue: T,
|
||||
stateSaver: Saver<T, out Any>,
|
||||
@BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
|
||||
): State<T> {
|
||||
val state = rememberSaveable(stateSaver = stateSaver) {
|
||||
mutableStateOf(initialValue)
|
||||
}
|
||||
|
||||
var produced by rememberSaveable {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
if (!produced) {
|
||||
ProduceSaveableStateScope(state, coroutineContext).producer()
|
||||
produced = true
|
||||
}
|
||||
}
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T> produceSaveableOneShotState(
|
||||
initialValue: T,
|
||||
|
||||
Reference in New Issue
Block a user