Skip to content

Compose

This module is placed inside the extension-compose and offers some helpful compose extensions for the Storage class.

collectAsState#

@Composable
fun <T> StorageSetting<T>.collectAsState(
    initialValue: T? = getCached()
): State<T?>
@Composable
fun <T, X> StorageSetting<T>.collectAsState(
    initialValue: T? = getCached(),
    mapper: (T) -> X
): State<X?>

collectAsStateNotNull#

@Composable
fun <T> StorageSetting<T>.collectAsStateNotNull(
    initialValue: T = getCached() ?: value
): State<T>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateNotNull(
    initialValue: T = getCached() ?: value,
    mapper: (T) -> X
): State<X>

asMutableState#

@Composable
fun <T> StorageSetting<T>.asMutableState(): MutableState<T>
@Composable
fun <T, X> StorageSetting<T>.asMutableState(
    mapper: (T) -> X,
    unmapper: (X) -> T,
): MutableState<X>