Compose runtime helper that synchronously reads resources during composition.
// Source: https://github.com/JetBrains/compose-multiplatform | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package org.jetbrains.compose.resources
import androidx.compose.runtime.*
@Composable
internal actual fun <T> rememberResourceState(
key1: Any,
getDefault: () -> T,
block: suspend (ResourceEnvironment) -> T
): State<T> {
val environment = LocalComposeEnvironment.current.rememberEnvironment()
return remember(key1, environment) {
mutableStateOf(
runResourceBlocking { block(environment) }
)
}
}
@Composable
internal actual fun <T> rememberResourceState(
key1: Any,
key2: Any,
getDefault: () -> T,
block: susp
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key