Compose
This module is placed inside the extension-compose
artifact and offers some helpful compose extensions for the Storage
class.
collectAsState*
functions#
@Composable
fun <T> StorageSetting<T>.collectAsState(
initialValue: T? = getCachedValue(),
apply: (flow: Flow<T>) -> Flow<T> = { it }
): State<T?>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateMapped(
initialValue: T? = getCachedValue(),
mapper: (T) -> X,
): State<X?>
collectAsStateNotNull
#
@Composable
fun <T> StorageSetting<T>.collectAsStateNotNull(
initialValue: T = getValueNotNull(),
apply: (flow: Flow<T>) -> Flow<T> = { it }
): State<T>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateMappedNotNull(
initialValue: T = getValueNotNull(),
mapper: (T) -> X,
): State<X>
asMutableState*
functions#
@Composable
fun <T, X> StorageSetting<T>.asMutableState(
mapper: (T) -> X,
unmapper: (X) -> T,
): MutableState<X?>
@Composable
fun <T : Any, X : Any> StorageSetting<T>.asMutableStateNotNull(
mapper: (T) -> X,
unmapper: (X) -> T,
): MutableState<X>
asStateFlow*
functions#
fun <T> StorageSetting<T>.asStateFlow(
scope: CoroutineScope,
started: SharingStarted = SharingStarted.WhileSubscribed(5_000),
apply: (flow: Flow<T>) -> Flow<T> = { it }
): StateFlow<T?>
fun <T> StorageSetting<T>.asStateFlow(
scope: CoroutineScope,
started: SharingStarted = SharingStarted.WhileSubscribed(5_000),
apply: (flow: Flow<T>) -> Flow<T> = { it }
): StateFlow<T?>