Compose
This module is placed inside the extension-compose artifact and offers some helpful compose extensions for the Storage class.
All extensions functions are on StorageSetting<T> and following are available:
Available extensions are listed below:
StorageSetting<T>.collectAsState(...) functions
StorageSetting<T>.collectAsStateNotNull(...) functions
StorageSetting<T>.collectAsStateWithLifecycle(...) functions
@Composable
fun <T> StorageSetting<T>.collectAsStateWithLifecycle(
lifecycle: Lifecycle,
initialValue: T? = tryGetValueNotNull(),
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext
): State<T?>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateWithLifecycle(
lifecycle: Lifecycle,
initialValue: T? = tryGetValueNotNull(),
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
mapper: (T) -> X,
): State<X?>
@Composable
fun <T> StorageSetting<T>.collectAsStateWithLifecycle(
initialValue: T? = tryGetValueNotNull(),
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext
): State<T?>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateWithLifecycle(
initialValue: T? = tryGetValueNotNull(),
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
mapper: (T) -> X,
): State<X?>
StorageSetting<T>.collectAsStateWithLifecycleNotNull(...) functions
@Composable
fun <T> StorageSetting<T>.collectAsStateWithLifecycleNotNull(
lifecycle: Lifecycle,
initialValue: T = getValueNotNull(),
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
): State<T>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateWithLifecycleNotNull(
lifecycle: Lifecycle,
initialValue: T = getValueNotNull(),
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
mapper: (T) -> X,
): State<X>
@Composable
fun <T> StorageSetting<T>.collectAsStateWithLifecycleNotNull(
initialValue: T = getValueNotNull(),
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext
): State<T>
@Composable
fun <T, X> StorageSetting<T>.collectAsStateWithLifecycleNotNull(
initialValue: T = getValueNotNull(),
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
mapper: (T) -> X,
): State<X>
StorageSetting<T>.asMutableState(...) functions
StorageSetting<T>.asMutableStateNotNull(...) functions
StorageSetting<T>.asMutableStateWithLifecycle(...) functions
@Composable
fun <T> StorageSetting<T>.asMutableStateWithLifecycle(
lifecycle: Lifecycle,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
): MutableState<T?>
@Composable
fun <T> StorageSetting<T>.asMutableStateWithLifecycle(
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
): MutableState<T?>
StorageSetting<T>.asMutableStateWithLifecycleNotNull(...) functions
@Composable
fun <T> StorageSetting<T>.asMutableStateWithLifecycleNotNull(
lifecycle: Lifecycle,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
): MutableState<T>
@Composable
fun <T> StorageSetting<T>.asMutableStateWithLifecycleNotNull(
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
): MutableState<T>
@Composable
fun <T : Any, X : Any> StorageSetting<T>.asMutableStateWithLifecycleNotNull(
lifecycle: Lifecycle,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
mapper: (T) -> X,
unmapper: (X) -> T,
): MutableState<X>
@Composable
fun <T : Any, X : Any> StorageSetting<T>.asMutableStateWithLifecycleNotNull(
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
context: CoroutineContext = EmptyCoroutineContext,
mapper: (T) -> X,
unmapper: (X) -> T,
): MutableState<X>