Break up SnapshotState.kt into separate files.
SnapshotState.kt is a large file with many different public APIs that
are all technically related to snapshot state but aren't otherwise
related to each other. For example, derivedStateOf and its
implementation is a non-trivial chunk of code that makes sense to have
its own file, and makes it a little easier for readers to tell which
code is related to what.
Preserves JVM binary compatibility by merging all new files introduced by
this change with the @JvmMultifileClass feature.
Test: ./gradlew :compose:r:r:tDUT
Relnote: """Snapshot code was split up into multiple files, but all still
lives in the same JVM class."""
Change-Id: Ic6c98dc9d1e4a85a2ef5acf099bc153b0d5f4146
diff --git a/compose/runtime/runtime/api/1.1.0-beta02.txt b/compose/runtime/runtime/api/1.1.0-beta02.txt
index 0ef7bba..d67558a 100644
--- a/compose/runtime/runtime/api/1.1.0-beta02.txt
+++ b/compose/runtime/runtime/api/1.1.0-beta02.txt
@@ -399,6 +399,106 @@
method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
}
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
@androidx.compose.runtime.StableMarker @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Stable {
}
diff --git a/compose/runtime/runtime/api/current.txt b/compose/runtime/runtime/api/current.txt
index 0ef7bba..d67558a 100644
--- a/compose/runtime/runtime/api/current.txt
+++ b/compose/runtime/runtime/api/current.txt
@@ -399,6 +399,106 @@
method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
}
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
@androidx.compose.runtime.StableMarker @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Stable {
}
diff --git a/compose/runtime/runtime/api/public_plus_experimental_1.1.0-beta02.txt b/compose/runtime/runtime/api/public_plus_experimental_1.1.0-beta02.txt
index 285197e..8c1d725 100644
--- a/compose/runtime/runtime/api/public_plus_experimental_1.1.0-beta02.txt
+++ b/compose/runtime/runtime/api/public_plus_experimental_1.1.0-beta02.txt
@@ -416,6 +416,106 @@
method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
}
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
@androidx.compose.runtime.StableMarker @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Stable {
}
diff --git a/compose/runtime/runtime/api/public_plus_experimental_current.txt b/compose/runtime/runtime/api/public_plus_experimental_current.txt
index 285197e..8c1d725 100644
--- a/compose/runtime/runtime/api/public_plus_experimental_current.txt
+++ b/compose/runtime/runtime/api/public_plus_experimental_current.txt
@@ -416,6 +416,106 @@
method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
}
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, @kotlin.BuilderInference kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
@androidx.compose.runtime.StableMarker @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Stable {
}
diff --git a/compose/runtime/runtime/api/restricted_1.1.0-beta02.txt b/compose/runtime/runtime/api/restricted_1.1.0-beta02.txt
index 0fae447..4f28290 100644
--- a/compose/runtime/runtime/api/restricted_1.1.0-beta02.txt
+++ b/compose/runtime/runtime/api/restricted_1.1.0-beta02.txt
@@ -425,6 +425,106 @@
method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
}
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
@androidx.compose.runtime.StableMarker @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Stable {
}
diff --git a/compose/runtime/runtime/api/restricted_current.txt b/compose/runtime/runtime/api/restricted_current.txt
index 0fae447..4f28290 100644
--- a/compose/runtime/runtime/api/restricted_current.txt
+++ b/compose/runtime/runtime/api/restricted_current.txt
@@ -425,6 +425,106 @@
method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
}
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
+ public final class SnapshotStateKt {
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> collectAsState(kotlinx.coroutines.flow.StateFlow<? extends T>, optional kotlin.coroutines.CoroutineContext context);
+ method @androidx.compose.runtime.Composable public static <T extends R, R> androidx.compose.runtime.State<R> collectAsState(kotlinx.coroutines.flow.Flow<? extends T>, R? initial, optional kotlin.coroutines.CoroutineContext context);
+ method public static <T> androidx.compose.runtime.State<T> derivedStateOf(kotlin.jvm.functions.Function0<? extends T> calculation);
+ method public static inline operator <T> T! getValue(androidx.compose.runtime.State<? extends T>, Object? thisObj, kotlin.reflect.KProperty<?> property);
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> mutableStateListOf(T?... elements);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf();
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> mutableStateMapOf(kotlin.Pair<? extends K,? extends V>... pairs);
+ method public static <T> androidx.compose.runtime.MutableState<T> mutableStateOf(T? value, optional androidx.compose.runtime.SnapshotMutationPolicy<T> policy);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> neverEqualPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object? key1, Object? key2, Object? key3, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> produceState(T? initialValue, Object![]? keys, kotlin.jvm.functions.Function2<? super androidx.compose.runtime.ProduceStateScope<T>,? super kotlin.coroutines.Continuation<? super kotlin.Unit>,?> producer);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> referentialEqualityPolicy();
+ method @androidx.compose.runtime.Composable public static <T> androidx.compose.runtime.State<T> rememberUpdatedState(T? newValue);
+ method public static inline operator <T> void setValue(androidx.compose.runtime.MutableState<T>, Object? thisObj, kotlin.reflect.KProperty<?> property, T? value);
+ method public static <T> kotlinx.coroutines.flow.Flow<T> snapshotFlow(kotlin.jvm.functions.Function0<? extends T> block);
+ method public static <T> androidx.compose.runtime.SnapshotMutationPolicy<T> structuralEqualityPolicy();
+ method public static <T> androidx.compose.runtime.snapshots.SnapshotStateList<T> toMutableStateList(java.util.Collection<? extends T>);
+ method public static <K, V> androidx.compose.runtime.snapshots.SnapshotStateMap<K,V> toMutableStateMap(Iterable<? extends kotlin.Pair<? extends K,? extends V>>);
+ }
+
@androidx.compose.runtime.StableMarker @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationTarget}) public @interface Stable {
}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/DerivedState.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/DerivedState.kt
new file mode 100644
index 0000000..ef047f9
--- /dev/null
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/DerivedState.kt
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:JvmName("SnapshotStateKt")
+@file:JvmMultifileClass
+package androidx.compose.runtime
+
+import androidx.compose.runtime.external.kotlinx.collections.immutable.PersistentList
+import androidx.compose.runtime.external.kotlinx.collections.immutable.persistentListOf
+import androidx.compose.runtime.snapshots.Snapshot
+import androidx.compose.runtime.snapshots.StateObject
+import androidx.compose.runtime.snapshots.StateRecord
+import androidx.compose.runtime.snapshots.fastForEach
+import androidx.compose.runtime.snapshots.newWritableRecord
+import androidx.compose.runtime.snapshots.readable
+import androidx.compose.runtime.snapshots.sync
+import androidx.compose.runtime.snapshots.withCurrent
+// Explicit imports for these needed in common source sets.
+import kotlin.jvm.JvmName
+import kotlin.jvm.JvmMultifileClass
+
+/**
+ * A [State] that is derived from one or more other states.
+ *
+ * @see derivedStateOf
+ */
+internal interface DerivedState<T> : State<T> {
+ /**
+ * The value of the derived state retrieved without triggering a notification to read observers.
+ */
+ val currentValue: T
+
+ /**
+ * A list of the dependencies used to produce [value] or [currentValue].
+ *
+ * The [dependencies] list can be used to determine when a [StateObject] appears in the apply
+ * observer set, if the state could affect value of this derived state.
+ */
+ val dependencies: Set<StateObject>
+}
+
+private typealias DerivedStateObservers = Pair<(DerivedState<*>) -> Unit, (DerivedState<*>) -> Unit>
+
+private val derivedStateObservers = SnapshotThreadLocal<PersistentList<DerivedStateObservers>>()
+
+private class DerivedSnapshotState<T>(
+ private val calculation: () -> T
+) : StateObject, DerivedState<T> {
+ private var first: ResultRecord<T> = ResultRecord()
+
+ private class ResultRecord<T> : StateRecord() {
+ var dependencies: HashSet<StateObject>? = null
+ var result: T? = null
+ var resultHash: Int = 0
+
+ override fun assign(value: StateRecord) {
+ @Suppress("UNCHECKED_CAST")
+ val other = value as ResultRecord<T>
+ dependencies = other.dependencies
+ result = other.result
+ resultHash = other.resultHash
+ }
+
+ override fun create(): StateRecord = ResultRecord<T>()
+
+ fun isValid(derivedState: DerivedState<*>, snapshot: Snapshot): Boolean =
+ result != null && resultHash == readableHash(derivedState, snapshot)
+
+ fun readableHash(derivedState: DerivedState<*>, snapshot: Snapshot): Int {
+ var hash = 7
+ val dependencies = sync { dependencies }
+ if (dependencies != null) {
+ notifyObservers(derivedState) {
+ for (stateObject in dependencies) {
+ // Find the first record without triggering an observer read.
+ val record = stateObject.firstStateRecord.readable(stateObject, snapshot)
+ hash = 31 * hash + identityHashCode(record)
+ hash = 31 * hash + record.snapshotId
+ }
+ }
+ }
+ return hash
+ }
+ }
+
+ private fun currentRecord(
+ readable: ResultRecord<T>,
+ snapshot: Snapshot,
+ calculation: () -> T
+ ): ResultRecord<T> {
+ if (readable.isValid(this, snapshot)) {
+ @Suppress("UNCHECKED_CAST")
+ return readable
+ }
+ val newDependencies = HashSet<StateObject>()
+ val result = notifyObservers(this) {
+ Snapshot.observe(
+ {
+ if (it === this)
+ error("A derived state cannot calculation cannot read itself")
+ if (it is StateObject) newDependencies.add(it)
+ },
+ null, calculation
+ )
+ }
+
+ val written = sync {
+ val writeSnapshot = Snapshot.current
+ val writable = first.newWritableRecord(this, writeSnapshot)
+ writable.dependencies = newDependencies
+ writable.resultHash = writable.readableHash(this, writeSnapshot)
+ writable.result = result
+ writable
+ }
+ Snapshot.notifyObjectsInitialized()
+
+ return written
+ }
+
+ override val firstStateRecord: StateRecord get() = first
+
+ override fun prependStateRecord(value: StateRecord) {
+ @Suppress("UNCHECKED_CAST")
+ first = value as ResultRecord<T>
+ }
+
+ override val value: T
+ get() {
+ // Unlike most state objects, the record list of a derived state can change during a read
+ // because reading updates the cache. To account for this, instead of calling readable,
+ // which sends the read notification, the read observer is notified directly and current
+ // value is used instead which doesn't notify. This allow the read observer to read the
+ // value and only update the cache once.
+ Snapshot.current.readObserver?.invoke(this)
+ return currentValue
+ }
+
+ override val currentValue: T
+ get() = first.withCurrent {
+ @Suppress("UNCHECKED_CAST")
+ currentRecord(it, Snapshot.current, calculation).result as T
+ }
+
+ override val dependencies: Set<StateObject>
+ get() = first.withCurrent {
+ currentRecord(it, Snapshot.current, calculation).dependencies ?: emptySet()
+ }
+
+ override fun toString(): String = first.withCurrent {
+ "DerivedState(value=${displayValue()})@${hashCode()}"
+ }
+
+ /**
+ * A function used by the debugger to display the value of the current value of the mutable
+ * state object without triggering read observers.
+ */
+ @Suppress("unused")
+ val debuggerDisplayValue: T?
+ @JvmName("getDebuggerDisplayValue")
+ get() = first.withCurrent {
+ if (it.isValid(this, Snapshot.current))
+ it.result
+ else null
+ }
+
+ private fun displayValue(): String {
+ first.withCurrent {
+ if (it.isValid(this, Snapshot.current)) {
+ return it.result.toString()
+ }
+ return "<Not calculated>"
+ }
+ }
+}
+
+private inline fun <R> notifyObservers(derivedState: DerivedState<*>, block: () -> R): R {
+ val observers = derivedStateObservers.get() ?: persistentListOf()
+ observers.fastForEach { (start, _) -> start(derivedState) }
+ return try {
+ block()
+ } finally {
+ observers.fastForEach { (_, done) -> done(derivedState) }
+ }
+}
+
+/**
+ * Creates a [State] object whose [State.value] is the result of [calculation]. The result of
+ * calculation will be cached in such a way that calling [State.value] repeatedly will not cause
+ * [calculation] to be executed multiple times, but reading [State.value] will cause all [State]
+ * objects that got read during the [calculation] to be read in the current [Snapshot], meaning
+ * that this will correctly subscribe to the derived state objects if the value is being read in
+ * an observed context such as a [Composable] function.
+ *
+ * @sample androidx.compose.runtime.samples.DerivedStateSample
+ *
+ * @param calculation the calculation to create the value this state object represents.
+ */
+fun <T> derivedStateOf(calculation: () -> T): State<T> = DerivedSnapshotState(calculation)
+
+/**
+ * Observe the recalculations performed by any derived state that is recalculated during the
+ * execution of [block]. [start] is called before a calculation starts and [done] is called
+ * after the started calculation is complete.
+ *
+ * @param start a lambda called before every calculation of a derived state is in [block].
+ * @param done a lambda that is called after the state passed to [start] is recalculated.
+ * @param block the block of code to observe.
+ */
+internal fun <R> observeDerivedStateRecalculations(
+ start: (derivedState: State<*>) -> Unit,
+ done: (derivedState: State<*>) -> Unit,
+ block: () -> R
+) {
+ val previous = derivedStateObservers.get()
+ try {
+ derivedStateObservers.set(
+ (derivedStateObservers.get() ?: persistentListOf()).add(
+ start to done
+ )
+ )
+ block()
+ } finally {
+ derivedStateObservers.set(previous)
+ }
+}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ProduceState.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ProduceState.kt
new file mode 100644
index 0000000..1b22fc9
--- /dev/null
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/ProduceState.kt
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:OptIn(ExperimentalTypeInference::class)
+@file:JvmName("SnapshotStateKt")
+@file:JvmMultifileClass
+package androidx.compose.runtime
+
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.suspendCancellableCoroutine
+import kotlin.coroutines.CoroutineContext
+import kotlin.experimental.ExperimentalTypeInference
+// Explicit imports for these needed in common source sets.
+import kotlin.jvm.JvmName
+import kotlin.jvm.JvmMultifileClass
+
+/**
+ * Receiver scope for use with [produceState].
+ */
+interface ProduceStateScope<T> : MutableState<T>, CoroutineScope {
+ /**
+ * Await the disposal of this producer whether it left the composition,
+ * the source changed, or an error occurred. Always runs [onDispose] before resuming.
+ *
+ * This method is useful when configuring callback-based state producers that do not suspend,
+ * for example:
+ *
+ * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
+ */
+ suspend fun awaitDispose(onDispose: () -> Unit): Nothing
+}
+
+private class ProduceStateScopeImpl<T>(
+ state: MutableState<T>,
+ override val coroutineContext: CoroutineContext
+) : ProduceStateScope<T>, MutableState<T> by state {
+
+ override suspend fun awaitDispose(onDispose: () -> Unit): Nothing {
+ try {
+ suspendCancellableCoroutine<Nothing> { }
+ } finally {
+ onDispose()
+ }
+ }
+}
+
+/**
+ * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
+ * produces values over time without a defined data source.
+ *
+ * [producer] is launched when [produceState] enters the composition and is cancelled when
+ * [produceState] leaves the composition. [producer] should use [ProduceStateScope.value]
+ * to set new values on the returned [State].
+ *
+ * The returned [State] conflates values; no change will be observable if
+ * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
+ * and observers may only see the latest value if several values are set in rapid succession.
+ *
+ * [produceState] may be used to observe either suspending or non-suspending sources of external
+ * data, for example:
+ *
+ * @sample androidx.compose.runtime.samples.ProduceState
+ *
+ * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
+ */
+@Composable
+fun <T> produceState(
+ initialValue: T,
+ @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
+): State<T> {
+ val result = remember { mutableStateOf(initialValue) }
+ LaunchedEffect(Unit) {
+ ProduceStateScopeImpl(result, coroutineContext).producer()
+ }
+ return result
+}
+
+/**
+ * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
+ * produces values over time from [key1].
+ *
+ * [producer] is launched when [produceState] enters the composition and is cancelled when
+ * [produceState] leaves the composition. If [key1] changes, a running [producer] will be
+ * cancelled and re-launched for the new source. [producer] should use [ProduceStateScope.value]
+ * to set new values on the returned [State].
+ *
+ * The returned [State] conflates values; no change will be observable if
+ * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
+ * and observers may only see the latest value if several values are set in rapid succession.
+ *
+ * [produceState] may be used to observe either suspending or non-suspending sources of external
+ * data, for example:
+ *
+ * @sample androidx.compose.runtime.samples.ProduceState
+ *
+ * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
+ */
+@Composable
+fun <T> produceState(
+ initialValue: T,
+ key1: Any?,
+ @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
+): State<T> {
+ val result = remember { mutableStateOf(initialValue) }
+ LaunchedEffect(key1) {
+ ProduceStateScopeImpl(result, coroutineContext).producer()
+ }
+ return result
+}
+
+/**
+ * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
+ * produces values over time from [key1] and [key2].
+ *
+ * [producer] is launched when [produceState] enters the composition and is cancelled when
+ * [produceState] leaves the composition. If [key1] or [key2] change, a running [producer]
+ * will be cancelled and re-launched for the new source. [producer] should use
+ * [ProduceStateScope.value] to set new values on the returned [State].
+ *
+ * The returned [State] conflates values; no change will be observable if
+ * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
+ * and observers may only see the latest value if several values are set in rapid succession.
+ *
+ * [produceState] may be used to observe either suspending or non-suspending sources of external
+ * data, for example:
+ *
+ * @sample androidx.compose.runtime.samples.ProduceState
+ *
+ * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
+ */
+@Composable
+fun <T> produceState(
+ initialValue: T,
+ key1: Any?,
+ key2: Any?,
+ @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
+): State<T> {
+ val result = remember { mutableStateOf(initialValue) }
+ LaunchedEffect(key1, key2) {
+ ProduceStateScopeImpl(result, coroutineContext).producer()
+ }
+ return result
+}
+
+/**
+ * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
+ * produces values over time from [key1], [key2] and [key3].
+ *
+ * [producer] is launched when [produceState] enters the composition and is cancelled when
+ * [produceState] leaves the composition. If [key1], [key2] or [key3] change, a running
+ * [producer] will be cancelled and re-launched for the new source. [producer should use
+ * [ProduceStateScope.value] to set new values on the returned [State].
+ *
+ * The returned [State] conflates values; no change will be observable if
+ * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
+ * and observers may only see the latest value if several values are set in rapid succession.
+ *
+ * [produceState] may be used to observe either suspending or non-suspending sources of external
+ * data, for example:
+ *
+ * @sample androidx.compose.runtime.samples.ProduceState
+ *
+ * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
+ */
+@Composable
+fun <T> produceState(
+ initialValue: T,
+ key1: Any?,
+ key2: Any?,
+ key3: Any?,
+ @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
+): State<T> {
+ val result = remember { mutableStateOf(initialValue) }
+ LaunchedEffect(key1, key2, key3) {
+ ProduceStateScopeImpl(result, coroutineContext).producer()
+ }
+ return result
+}
+
+/**
+ * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
+ * produces values over time from [keys].
+ *
+ * [producer] is launched when [produceState] enters the composition and is cancelled when
+ * [produceState] leaves the composition. If [keys] change, a running [producer] will be
+ * cancelled and re-launched for the new source. [producer] should use [ProduceStateScope.value]
+ * to set new values on the returned [State].
+ *
+ * The returned [State] conflates values; no change will be observable if
+ * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
+ * and observers may only see the latest value if several values are set in rapid succession.
+ *
+ * [produceState] may be used to observe either suspending or non-suspending sources of external
+ * data, for example:
+ *
+ * @sample androidx.compose.runtime.samples.ProduceState
+ *
+ * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
+ */
+@Composable
+fun <T> produceState(
+ initialValue: T,
+ vararg keys: Any?,
+ @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
+): State<T> {
+ val result = remember { mutableStateOf(initialValue) }
+ @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
+ LaunchedEffect(keys = keys) {
+ ProduceStateScopeImpl(result, coroutineContext).producer()
+ }
+ return result
+}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotFlow.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotFlow.kt
new file mode 100644
index 0000000..12250ab
--- /dev/null
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotFlow.kt
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:JvmName("SnapshotStateKt")
+@file:JvmMultifileClass
+package androidx.compose.runtime
+
+import androidx.compose.runtime.snapshots.Snapshot
+import kotlinx.coroutines.channels.Channel
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.collect
+import kotlinx.coroutines.flow.flow
+import kotlinx.coroutines.withContext
+import kotlin.coroutines.CoroutineContext
+import kotlin.coroutines.EmptyCoroutineContext
+// Explicit imports for these needed in common source sets.
+import kotlin.jvm.JvmName
+import kotlin.jvm.JvmMultifileClass
+
+/**
+ * Collects values from this [StateFlow] and represents its latest value via [State].
+ * The [StateFlow.value] is used as an initial value. Every time there would be new value posted
+ * into the [StateFlow] the returned [State] will be updated causing recomposition of every
+ * [State.value] usage.
+ *
+ * @sample androidx.compose.runtime.samples.StateFlowSample
+ *
+ * @param context [CoroutineContext] to use for collecting.
+ */
+@Suppress("StateFlowValueCalledInComposition")
+@Composable
+fun <T> StateFlow<T>.collectAsState(
+ context: CoroutineContext = EmptyCoroutineContext
+): State<T> = collectAsState(value, context)
+
+/**
+ * Collects values from this [Flow] and represents its latest value via [State]. Every time there
+ * would be new value posted into the [Flow] the returned [State] will be updated causing
+ * recomposition of every [State.value] usage.
+ *
+ * @sample androidx.compose.runtime.samples.FlowWithInitialSample
+ *
+ * @param context [CoroutineContext] to use for collecting.
+ */
+@Composable
+fun <T : R, R> Flow<T>.collectAsState(
+ initial: R,
+ context: CoroutineContext = EmptyCoroutineContext
+): State<R> = produceState(initial, this, context) {
+ if (context == EmptyCoroutineContext) {
+ collect { value = it }
+ } else withContext(context) {
+ collect { value = it }
+ }
+}
+
+/**
+ * Create a [Flow] from observable [Snapshot] state. (e.g. state holders returned by
+ * [mutableStateOf][androidx.compose.runtime.mutableStateOf].)
+ *
+ * [snapshotFlow] creates a [Flow] that runs [block] when collected and emits the result,
+ * recording any snapshot state that was accessed. While collection continues, if a new [Snapshot]
+ * is applied that changes state accessed by [block], the flow will run [block] again,
+ * re-recording the snapshot state that was accessed.
+ * If the result of [block] is not [equal to][Any.equals] the previous result, the flow will emit
+ * that new result. (This behavior is similar to that of
+ * [Flow.distinctUntilChanged][kotlinx.coroutines.flow.distinctUntilChanged].) Collection will
+ * continue indefinitely unless it is explicitly cancelled or limited by the use of other [Flow]
+ * operators.
+ *
+ * @sample androidx.compose.runtime.samples.snapshotFlowSample
+ *
+ * [block] is run in a **read-only** [Snapshot] and may not modify snapshot data. If [block]
+ * attempts to modify snapshot data, flow collection will fail with [IllegalStateException].
+ *
+ * [block] may run more than once for equal sets of inputs or only once after many rapid
+ * snapshot changes; it should be idempotent and free of side effects.
+ *
+ * When working with [Snapshot] state it is useful to keep the distinction between **events** and
+ * **state** in mind. [snapshotFlow] models snapshot changes as events, but events **cannot** be
+ * effectively modeled as observable state. Observable state is a lossy compression of the events
+ * that produced that state.
+ *
+ * An observable **event** happens at a point in time and is discarded. All registered observers
+ * at the time the event occurred are notified. All individual events in a stream are assumed
+ * to be relevant and may build on one another; repeated equal events have meaning and therefore
+ * a registered observer must observe all events without skipping.
+ *
+ * Observable **state** raises change events when the state changes from one value to a new,
+ * unequal value. State change events are **conflated;** only the most recent state matters.
+ * Observers of state changes must therefore be **idempotent;** given the same state value the
+ * observer should produce the same result. It is valid for a state observer to both skip
+ * intermediate states as well as run multiple times for the same state and the result should
+ * be the same.
+ */
+fun <T> snapshotFlow(
+ block: () -> T
+): Flow<T> = flow {
+ // Objects read the last time block was run
+ val readSet = mutableSetOf<Any>()
+ val readObserver: (Any) -> Unit = { readSet.add(it) }
+
+ // This channel may not block or lose data on a trySend call.
+ val appliedChanges = Channel<Set<Any>>(Channel.UNLIMITED)
+
+ // Register the apply observer before running for the first time
+ // so that we don't miss updates.
+ val unregisterApplyObserver = Snapshot.registerApplyObserver { changed, _ ->
+ appliedChanges.trySend(changed)
+ }
+
+ try {
+ var lastValue = Snapshot.takeSnapshot(readObserver).run {
+ try {
+ enter(block)
+ } finally {
+ dispose()
+ }
+ }
+ emit(lastValue)
+
+ while (true) {
+ var found = false
+ var changedObjects = appliedChanges.receive()
+
+ // Poll for any other changes before running block to minimize the number of
+ // additional times it runs for the same data
+ while (true) {
+ // Assumption: readSet will typically be smaller than changed
+ found = found || readSet.intersects(changedObjects)
+ changedObjects = appliedChanges.tryReceive().getOrNull() ?: break
+ }
+
+ if (found) {
+ readSet.clear()
+ val newValue = Snapshot.takeSnapshot(readObserver).run {
+ try {
+ enter(block)
+ } finally {
+ dispose()
+ }
+ }
+
+ if (newValue != lastValue) {
+ lastValue = newValue
+ emit(newValue)
+ }
+ }
+ }
+ } finally {
+ unregisterApplyObserver.dispose()
+ }
+}
+
+/**
+ * Return `true` if there are any elements shared between `this` and [other]
+ */
+private fun <T> Set<T>.intersects(other: Set<T>): Boolean =
+ if (size < other.size) any { it in other } else other.any { it in this }
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotMutationPolicy.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotMutationPolicy.kt
new file mode 100644
index 0000000..bb6ca6a
--- /dev/null
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotMutationPolicy.kt
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:JvmName("SnapshotStateKt")
+@file:JvmMultifileClass
+package androidx.compose.runtime
+
+import androidx.compose.runtime.snapshots.MutableSnapshot
+// Explicit imports for these needed in common source sets.
+import kotlin.jvm.JvmName
+import kotlin.jvm.JvmMultifileClass
+
+/**
+ * A policy to control how the result of [mutableStateOf] report and merge changes to
+ * the state object.
+ *
+ * A mutation policy can be passed as an parameter to [mutableStateOf], and [compositionLocalOf].
+ *
+ * Typically, one of the stock policies should be used such as [referentialEqualityPolicy],
+ * [structuralEqualityPolicy], or [neverEqualPolicy]. However, a custom mutation policy can be
+ * created by implementing this interface, such as a counter policy,
+ *
+ * @sample androidx.compose.runtime.samples.counterSample
+ */
+interface SnapshotMutationPolicy<T> {
+ /**
+ * Determine if setting a state value's are equivalent and should be treated as equal. If
+ * [equivalent] returns `true` the new value is not considered a change.
+ */
+ fun equivalent(a: T, b: T): Boolean
+
+ /**
+ * Merge conflicting changes in snapshots. This is only called if [current] and [applied] are
+ * not [equivalent]. If a valid merged value can be calculated then it should be returned.
+ *
+ * For example, if the state object holds an immutable data class with multiple fields,
+ * and [applied] has changed fields that are unmodified by [current] it might be valid to return
+ * a new copy of the data class that combines that changes from both [current] and [applied]
+ * allowing a snapshot to apply that would have otherwise failed.
+ *
+ * @sample androidx.compose.runtime.samples.counterSample
+ */
+ fun merge(previous: T, current: T, applied: T): T? = null
+}
+
+/**
+ * A policy to treat values of a [MutableState] as equivalent if they are referentially (===) equal.
+ *
+ * Setting [MutableState.value] to its current referentially (===) equal value is not considered
+ * a change. When applying a [MutableSnapshot], if the snapshot changes the value to the
+ * equivalent value the parent snapshot has is not considered a conflict.
+ */
+@Suppress("UNCHECKED_CAST")
+fun <T> referentialEqualityPolicy(): SnapshotMutationPolicy<T> =
+ ReferentialEqualityPolicy as SnapshotMutationPolicy<T>
+
+private object ReferentialEqualityPolicy : SnapshotMutationPolicy<Any?> {
+ override fun equivalent(a: Any?, b: Any?) = a === b
+
+ override fun toString() = "ReferentialEqualityPolicy"
+}
+
+/**
+ * A policy to treat values of a [MutableState] as equivalent if they are structurally (==) equal.
+ *
+ * Setting [MutableState.value] to its current structurally (==) equal value is not considered
+ * a change. When applying a [MutableSnapshot], if the snapshot changes the value to the
+ * equivalent value the parent snapshot has is not considered a conflict.
+ */
+@Suppress("UNCHECKED_CAST")
+fun <T> structuralEqualityPolicy(): SnapshotMutationPolicy<T> =
+ StructuralEqualityPolicy as SnapshotMutationPolicy<T>
+
+private object StructuralEqualityPolicy : SnapshotMutationPolicy<Any?> {
+ override fun equivalent(a: Any?, b: Any?) = a == b
+
+ override fun toString() = "StructuralEqualityPolicy"
+}
+
+/**
+ * A policy never treat values of a [MutableState] as equivalent.
+ *
+ * Setting [MutableState.value] will always be considered a change. When applying a
+ * [MutableSnapshot] that changes the state will always conflict with other snapshots that change
+ * the same state.
+ */
+@Suppress("UNCHECKED_CAST")
+fun <T> neverEqualPolicy(): SnapshotMutationPolicy<T> =
+ NeverEqualPolicy as SnapshotMutationPolicy<T>
+
+private object NeverEqualPolicy : SnapshotMutationPolicy<Any?> {
+ override fun equivalent(a: Any?, b: Any?) = false
+
+ override fun toString() = "NeverEqualPolicy"
+}
diff --git a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotState.kt b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotState.kt
index 65c4e73..343cd1a 100644
--- a/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotState.kt
+++ b/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/SnapshotState.kt
@@ -14,37 +14,22 @@
* limitations under the License.
*/
-@file:OptIn(ExperimentalTypeInference::class)
-
+@file:JvmName("SnapshotStateKt")
+@file:JvmMultifileClass
package androidx.compose.runtime
-import androidx.compose.runtime.external.kotlinx.collections.immutable.PersistentList
-import androidx.compose.runtime.external.kotlinx.collections.immutable.persistentListOf
-import androidx.compose.runtime.snapshots.MutableSnapshot
import androidx.compose.runtime.snapshots.Snapshot
import androidx.compose.runtime.snapshots.SnapshotMutableState
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.runtime.snapshots.SnapshotStateMap
import androidx.compose.runtime.snapshots.StateObject
import androidx.compose.runtime.snapshots.StateRecord
-import androidx.compose.runtime.snapshots.fastForEach
-import androidx.compose.runtime.snapshots.newWritableRecord
import androidx.compose.runtime.snapshots.overwritable
import androidx.compose.runtime.snapshots.readable
-import androidx.compose.runtime.snapshots.sync
import androidx.compose.runtime.snapshots.withCurrent
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.channels.Channel
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.StateFlow
-import kotlinx.coroutines.flow.collect
-import kotlinx.coroutines.flow.flow
-import kotlinx.coroutines.suspendCancellableCoroutine
-import kotlinx.coroutines.withContext
-import kotlin.coroutines.CoroutineContext
-import kotlin.coroutines.EmptyCoroutineContext
-import kotlin.experimental.ExperimentalTypeInference
+// Explicit imports for jvm annotations needed in common source sets.
import kotlin.jvm.JvmName
+import kotlin.jvm.JvmMultifileClass
import kotlin.reflect.KProperty
/**
@@ -226,91 +211,7 @@
}
/**
- * A policy to control how the result of [mutableStateOf] report and merge changes to
- * the state object.
- *
- * A mutation policy can be passed as an parameter to [mutableStateOf], and [compositionLocalOf].
- *
- * Typically, one of the stock policies should be used such as [referentialEqualityPolicy],
- * [structuralEqualityPolicy], or [neverEqualPolicy]. However, a custom mutation policy can be
- * created by implementing this interface, such as a counter policy,
- *
- * @sample androidx.compose.runtime.samples.counterSample
- */
-interface SnapshotMutationPolicy<T> {
- /**
- * Determine if setting a state value's are equivalent and should be treated as equal. If
- * [equivalent] returns `true` the new value is not considered a change.
- */
- fun equivalent(a: T, b: T): Boolean
-
- /**
- * Merge conflicting changes in snapshots. This is only called if [current] and [applied] are
- * not [equivalent]. If a valid merged value can be calculated then it should be returned.
- *
- * For example, if the state object holds an immutable data class with multiple fields,
- * and [applied] has changed fields that are unmodified by [current] it might be valid to return
- * a new copy of the data class that combines that changes from both [current] and [applied]
- * allowing a snapshot to apply that would have otherwise failed.
- *
- * @sample androidx.compose.runtime.samples.counterSample
- */
- fun merge(previous: T, current: T, applied: T): T? = null
-}
-
-/**
- * A policy to treat values of a [MutableState] as equivalent if they are referentially (===) equal.
- *
- * Setting [MutableState.value] to its current referentially (===) equal value is not considered
- * a change. When applying a [MutableSnapshot], if the snapshot changes the value to the
- * equivalent value the parent snapshot has is not considered a conflict.
- */
-@Suppress("UNCHECKED_CAST")
-fun <T> referentialEqualityPolicy(): SnapshotMutationPolicy<T> =
- ReferentialEqualityPolicy as SnapshotMutationPolicy<T>
-
-private object ReferentialEqualityPolicy : SnapshotMutationPolicy<Any?> {
- override fun equivalent(a: Any?, b: Any?) = a === b
-
- override fun toString() = "ReferentialEqualityPolicy"
-}
-
-/**
- * A policy to treat values of a [MutableState] as equivalent if they are structurally (==) equal.
- *
- * Setting [MutableState.value] to its current structurally (==) equal value is not considered
- * a change. When applying a [MutableSnapshot], if the snapshot changes the value to the
- * equivalent value the parent snapshot has is not considered a conflict.
- */
-@Suppress("UNCHECKED_CAST")
-fun <T> structuralEqualityPolicy(): SnapshotMutationPolicy<T> =
- StructuralEqualityPolicy as SnapshotMutationPolicy<T>
-
-private object StructuralEqualityPolicy : SnapshotMutationPolicy<Any?> {
- override fun equivalent(a: Any?, b: Any?) = a == b
-
- override fun toString() = "StructuralEqualityPolicy"
-}
-
-/**
- * A policy never treat values of a [MutableState] as equivalent.
- *
- * Setting [MutableState.value] will always be considered a change. When applying a
- * [MutableSnapshot] that changes the state will always conflict with other snapshots that change
- * the same state.
- */
-@Suppress("UNCHECKED_CAST")
-fun <T> neverEqualPolicy(): SnapshotMutationPolicy<T> =
- NeverEqualPolicy as SnapshotMutationPolicy<T>
-
-private object NeverEqualPolicy : SnapshotMutationPolicy<Any?> {
- override fun equivalent(a: Any?, b: Any?) = false
-
- override fun toString() = "NeverEqualPolicy"
-}
-
-/**
- * Create a instance of MutableList<T> that is observable and can be snapshot.
+ * Create a instance of [MutableList]<T> that is observable and can be snapshot.
*
* @sample androidx.compose.runtime.samples.stateListSample
*
@@ -322,7 +223,7 @@
fun <T> mutableStateListOf() = SnapshotStateList<T>()
/**
- * Create an instance of MutableList<T> that is observable and can be snapshot.
+ * Create an instance of [MutableList]<T> that is observable and can be snapshot.
*
* @see mutableStateOf
* @see mutableListOf
@@ -370,408 +271,6 @@
SnapshotStateMap<K, V>().also { it.putAll(this.toMap()) }
/**
- * A [State] that is derived from one or more other states.
- *
- * @see derivedStateOf
- */
-internal interface DerivedState<T> : State<T> {
- /**
- * The value of the derived state retrieved without triggering a notification to read observers.
- */
- val currentValue: T
-
- /**
- * A list of the dependencies used to produce [value] or [currentValue].
- *
- * The [dependencies] list can be used to determine when a [StateObject] appears in the apply
- * observer set, if the state could affect value of this derived state.
- */
- val dependencies: Set<StateObject>
-}
-
-private typealias DerivedStateObservers = Pair<(DerivedState<*>) -> Unit, (DerivedState<*>) -> Unit>
-
-private val derivedStateObservers = SnapshotThreadLocal<PersistentList<DerivedStateObservers>>()
-
-private class DerivedSnapshotState<T>(
- private val calculation: () -> T
-) : StateObject, DerivedState<T> {
- private var first: ResultRecord<T> = ResultRecord()
-
- private class ResultRecord<T> : StateRecord() {
- var dependencies: HashSet<StateObject>? = null
- var result: T? = null
- var resultHash: Int = 0
-
- override fun assign(value: StateRecord) {
- @Suppress("UNCHECKED_CAST")
- val other = value as ResultRecord<T>
- dependencies = other.dependencies
- result = other.result
- resultHash = other.resultHash
- }
-
- override fun create(): StateRecord = ResultRecord<T>()
-
- fun isValid(derivedState: DerivedState<*>, snapshot: Snapshot): Boolean =
- result != null && resultHash == readableHash(derivedState, snapshot)
-
- fun readableHash(derivedState: DerivedState<*>, snapshot: Snapshot): Int {
- var hash = 7
- val dependencies = sync { dependencies }
- if (dependencies != null) {
- notifyObservers(derivedState) {
- for (stateObject in dependencies) {
- // Find the first record without triggering an observer read.
- val record = stateObject.firstStateRecord.readable(stateObject, snapshot)
- hash = 31 * hash + identityHashCode(record)
- hash = 31 * hash + record.snapshotId
- }
- }
- }
- return hash
- }
- }
-
- private fun currentRecord(
- readable: ResultRecord<T>,
- snapshot: Snapshot,
- calculation: () -> T
- ): ResultRecord<T> {
- if (readable.isValid(this, snapshot)) {
- @Suppress("UNCHECKED_CAST")
- return readable
- }
- val newDependencies = HashSet<StateObject>()
- val result = notifyObservers(this) {
- Snapshot.observe(
- {
- if (it === this)
- error("A derived state cannot calculation cannot read itself")
- if (it is StateObject) newDependencies.add(it)
- },
- null, calculation
- )
- }
-
- val written = sync {
- val writeSnapshot = Snapshot.current
- val writable = first.newWritableRecord(this, writeSnapshot)
- writable.dependencies = newDependencies
- writable.resultHash = writable.readableHash(this, writeSnapshot)
- writable.result = result
- writable
- }
- Snapshot.notifyObjectsInitialized()
-
- return written
- }
-
- override val firstStateRecord: StateRecord get() = first
-
- override fun prependStateRecord(value: StateRecord) {
- @Suppress("UNCHECKED_CAST")
- first = value as ResultRecord<T>
- }
-
- override val value: T
- get() {
- // Unlike most state objects, the record list of a derived state can change during a read
- // because reading updates the cache. To account for this, instead of calling readable,
- // which sends the read notification, the read observer is notified directly and current
- // value is used instead which doesn't notify. This allow the read observer to read the
- // value and only update the cache once.
- Snapshot.current.readObserver?.invoke(this)
- return currentValue
- }
-
- override val currentValue: T
- get() = first.withCurrent {
- @Suppress("UNCHECKED_CAST")
- currentRecord(it, Snapshot.current, calculation).result as T
- }
-
- override val dependencies: Set<StateObject>
- get() = first.withCurrent {
- currentRecord(it, Snapshot.current, calculation).dependencies ?: emptySet()
- }
-
- override fun toString(): String = first.withCurrent {
- "DerivedState(value=${displayValue()})@${hashCode()}"
- }
-
- /**
- * A function used by the debugger to display the value of the current value of the mutable
- * state object without triggering read observers.
- */
- @Suppress("unused")
- val debuggerDisplayValue: T?
- @JvmName("getDebuggerDisplayValue")
- get() = first.withCurrent {
- if (it.isValid(this, Snapshot.current))
- it.result
- else null
- }
-
- private fun displayValue(): String {
- first.withCurrent {
- if (it.isValid(this, Snapshot.current)) {
- return it.result.toString()
- }
- return "<Not calculated>"
- }
- }
-}
-
-private inline fun <R> notifyObservers(derivedState: DerivedState<*>, block: () -> R): R {
- val observers = derivedStateObservers.get() ?: persistentListOf()
- observers.fastForEach { (start, _) -> start(derivedState) }
- return try {
- block()
- } finally {
- observers.fastForEach { (_, done) -> done(derivedState) }
- }
-}
-
-/**
- * Creates a [State] object whose [State.value] is the result of [calculation]. The result of
- * calculation will be cached in such a way that calling [State.value] repeatedly will not cause
- * [calculation] to be executed multiple times, but reading [State.value] will cause all [State]
- * objects that got read during the [calculation] to be read in the current [Snapshot], meaning
- * that this will correctly subscribe to the derived state objects if the value is being read in
- * an observed context such as a [Composable] function.
- *
- * @sample androidx.compose.runtime.samples.DerivedStateSample
- *
- * @param calculation the calculation to create the value this state object represents.
- */
-fun <T> derivedStateOf(calculation: () -> T): State<T> = DerivedSnapshotState(calculation)
-
-/**
- * Observe the recalculations performed by any derived state that is recalculated during the
- * execution of [block]. [start] is called before a calculation starts and [done] is called
- * after the started calculation is complete.
- *
- * @param start a lambda called before every calculation of a derived state is in [block].
- * @param done a lambda that is called after the state passed to [start] is recalculated.
- * @param block the block of code to observe.
- */
-internal fun <R> observeDerivedStateRecalculations(
- start: (derivedState: State<*>) -> Unit,
- done: (derivedState: State<*>) -> Unit,
- block: () -> R
-) {
- val previous = derivedStateObservers.get()
- try {
- derivedStateObservers.set(
- (derivedStateObservers.get() ?: persistentListOf()).add(
- start to done
- )
- )
- block()
- } finally {
- derivedStateObservers.set(previous)
- }
-}
-
-/**
- * Receiver scope for use with [produceState].
- */
-interface ProduceStateScope<T> : MutableState<T>, CoroutineScope {
- /**
- * Await the disposal of this producer whether it left the composition,
- * the source changed, or an error occurred. Always runs [onDispose] before resuming.
- *
- * This method is useful when configuring callback-based state producers that do not suspend,
- * for example:
- *
- * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
- */
- suspend fun awaitDispose(onDispose: () -> Unit): Nothing
-}
-
-private class ProduceStateScopeImpl<T>(
- state: MutableState<T>,
- override val coroutineContext: CoroutineContext
-) : ProduceStateScope<T>, MutableState<T> by state {
-
- override suspend fun awaitDispose(onDispose: () -> Unit): Nothing {
- try {
- suspendCancellableCoroutine<Nothing> { }
- } finally {
- onDispose()
- }
- }
-}
-
-/**
- * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
- * produces values over time without a defined data source.
- *
- * [producer] is launched when [produceState] enters the composition and is cancelled when
- * [produceState] leaves the composition. [producer] should use [ProduceStateScope.value]
- * to set new values on the returned [State].
- *
- * The returned [State] conflates values; no change will be observable if
- * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
- * and observers may only see the latest value if several values are set in rapid succession.
- *
- * [produceState] may be used to observe either suspending or non-suspending sources of external
- * data, for example:
- *
- * @sample androidx.compose.runtime.samples.ProduceState
- *
- * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
- */
-@Composable
-fun <T> produceState(
- initialValue: T,
- @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
-): State<T> {
- val result = remember { mutableStateOf(initialValue) }
- LaunchedEffect(Unit) {
- ProduceStateScopeImpl(result, coroutineContext).producer()
- }
- return result
-}
-
-/**
- * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
- * produces values over time from [key1].
- *
- * [producer] is launched when [produceState] enters the composition and is cancelled when
- * [produceState] leaves the composition. If [key1] changes, a running [producer] will be
- * cancelled and re-launched for the new source. [producer] should use [ProduceStateScope.value]
- * to set new values on the returned [State].
- *
- * The returned [State] conflates values; no change will be observable if
- * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
- * and observers may only see the latest value if several values are set in rapid succession.
- *
- * [produceState] may be used to observe either suspending or non-suspending sources of external
- * data, for example:
- *
- * @sample androidx.compose.runtime.samples.ProduceState
- *
- * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
- */
-@Composable
-fun <T> produceState(
- initialValue: T,
- key1: Any?,
- @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
-): State<T> {
- val result = remember { mutableStateOf(initialValue) }
- LaunchedEffect(key1) {
- ProduceStateScopeImpl(result, coroutineContext).producer()
- }
- return result
-}
-
-/**
- * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
- * produces values over time from [key1] and [key2].
- *
- * [producer] is launched when [produceState] enters the composition and is cancelled when
- * [produceState] leaves the composition. If [key1] or [key2] change, a running [producer]
- * will be cancelled and re-launched for the new source. [producer] should use
- * [ProduceStateScope.value] to set new values on the returned [State].
- *
- * The returned [State] conflates values; no change will be observable if
- * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
- * and observers may only see the latest value if several values are set in rapid succession.
- *
- * [produceState] may be used to observe either suspending or non-suspending sources of external
- * data, for example:
- *
- * @sample androidx.compose.runtime.samples.ProduceState
- *
- * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
- */
-@Composable
-fun <T> produceState(
- initialValue: T,
- key1: Any?,
- key2: Any?,
- @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
-): State<T> {
- val result = remember { mutableStateOf(initialValue) }
- LaunchedEffect(key1, key2) {
- ProduceStateScopeImpl(result, coroutineContext).producer()
- }
- return result
-}
-
-/**
- * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
- * produces values over time from [key1], [key2] and [key3].
- *
- * [producer] is launched when [produceState] enters the composition and is cancelled when
- * [produceState] leaves the composition. If [key1], [key2] or [key3] change, a running
- * [producer] will be cancelled and re-launched for the new source. [producer should use
- * [ProduceStateScope.value] to set new values on the returned [State].
- *
- * The returned [State] conflates values; no change will be observable if
- * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
- * and observers may only see the latest value if several values are set in rapid succession.
- *
- * [produceState] may be used to observe either suspending or non-suspending sources of external
- * data, for example:
- *
- * @sample androidx.compose.runtime.samples.ProduceState
- *
- * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
- */
-@Composable
-fun <T> produceState(
- initialValue: T,
- key1: Any?,
- key2: Any?,
- key3: Any?,
- @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
-): State<T> {
- val result = remember { mutableStateOf(initialValue) }
- LaunchedEffect(key1, key2, key3) {
- ProduceStateScopeImpl(result, coroutineContext).producer()
- }
- return result
-}
-
-/**
- * Return an observable [snapshot][androidx.compose.runtime.snapshots.Snapshot] [State] that
- * produces values over time from [keys].
- *
- * [producer] is launched when [produceState] enters the composition and is cancelled when
- * [produceState] leaves the composition. If [keys] change, a running [producer] will be
- * cancelled and re-launched for the new source. [producer] should use [ProduceStateScope.value]
- * to set new values on the returned [State].
- *
- * The returned [State] conflates values; no change will be observable if
- * [ProduceStateScope.value] is used to set a value that is [equal][Any.equals] to its old value,
- * and observers may only see the latest value if several values are set in rapid succession.
- *
- * [produceState] may be used to observe either suspending or non-suspending sources of external
- * data, for example:
- *
- * @sample androidx.compose.runtime.samples.ProduceState
- *
- * @sample androidx.compose.runtime.samples.ProduceStateAwaitDispose
- */
-@Composable
-fun <T> produceState(
- initialValue: T,
- vararg keys: Any?,
- @BuilderInference producer: suspend ProduceStateScope<T>.() -> Unit
-): State<T> {
- val result = remember { mutableStateOf(initialValue) }
- @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
- LaunchedEffect(keys = keys) {
- ProduceStateScopeImpl(result, coroutineContext).producer()
- }
- return result
-}
-
-/**
* [remember] a [mutableStateOf] [newValue] and update its value to [newValue] on each
* recomposition of the [rememberUpdatedState] call.
*
@@ -796,144 +295,3 @@
fun <T> rememberUpdatedState(newValue: T): State<T> = remember {
mutableStateOf(newValue)
}.apply { value = newValue }
-
-/**
- * Collects values from this [StateFlow] and represents its latest value via [State].
- * The [StateFlow.value] is used as an initial value. Every time there would be new value posted
- * into the [StateFlow] the returned [State] will be updated causing recomposition of every
- * [State.value] usage.
- *
- * @sample androidx.compose.runtime.samples.StateFlowSample
- *
- * @param context [CoroutineContext] to use for collecting.
- */
-@Suppress("StateFlowValueCalledInComposition")
-@Composable
-fun <T> StateFlow<T>.collectAsState(
- context: CoroutineContext = EmptyCoroutineContext
-): State<T> = collectAsState(value, context)
-
-/**
- * Collects values from this [Flow] and represents its latest value via [State]. Every time there
- * would be new value posted into the [Flow] the returned [State] will be updated causing
- * recomposition of every [State.value] usage.
- *
- * @sample androidx.compose.runtime.samples.FlowWithInitialSample
- *
- * @param context [CoroutineContext] to use for collecting.
- */
-@Composable
-fun <T : R, R> Flow<T>.collectAsState(
- initial: R,
- context: CoroutineContext = EmptyCoroutineContext
-): State<R> = produceState(initial, this, context) {
- if (context == EmptyCoroutineContext) {
- collect { value = it }
- } else withContext(context) {
- collect { value = it }
- }
-}
-
-/**
- * Create a [Flow] from observable [Snapshot] state. (e.g. state holders returned by
- * [mutableStateOf][androidx.compose.runtime.mutableStateOf].)
- *
- * [snapshotFlow] creates a [Flow] that runs [block] when collected and emits the result,
- * recording any snapshot state that was accessed. While collection continues, if a new [Snapshot]
- * is applied that changes state accessed by [block], the flow will run [block] again,
- * re-recording the snapshot state that was accessed.
- * If the result of [block] is not [equal to][Any.equals] the previous result, the flow will emit
- * that new result. (This behavior is similar to that of
- * [Flow.distinctUntilChanged][kotlinx.coroutines.flow.distinctUntilChanged].) Collection will
- * continue indefinitely unless it is explicitly cancelled or limited by the use of other [Flow]
- * operators.
- *
- * @sample androidx.compose.runtime.samples.snapshotFlowSample
- *
- * [block] is run in a **read-only** [Snapshot] and may not modify snapshot data. If [block]
- * attempts to modify snapshot data, flow collection will fail with [IllegalStateException].
- *
- * [block] may run more than once for equal sets of inputs or only once after many rapid
- * snapshot changes; it should be idempotent and free of side effects.
- *
- * When working with [Snapshot] state it is useful to keep the distinction between **events** and
- * **state** in mind. [snapshotFlow] models snapshot changes as events, but events **cannot** be
- * effectively modeled as observable state. Observable state is a lossy compression of the events
- * that produced that state.
- *
- * An observable **event** happens at a point in time and is discarded. All registered observers
- * at the time the event occurred are notified. All individual events in a stream are assumed
- * to be relevant and may build on one another; repeated equal events have meaning and therefore
- * a registered observer must observe all events without skipping.
- *
- * Observable **state** raises change events when the state changes from one value to a new,
- * unequal value. State change events are **conflated;** only the most recent state matters.
- * Observers of state changes must therefore be **idempotent;** given the same state value the
- * observer should produce the same result. It is valid for a state observer to both skip
- * intermediate states as well as run multiple times for the same state and the result should
- * be the same.
- */
-fun <T> snapshotFlow(
- block: () -> T
-): Flow<T> = flow {
- // Objects read the last time block was run
- val readSet = mutableSetOf<Any>()
- val readObserver: (Any) -> Unit = { readSet.add(it) }
-
- // This channel may not block or lose data on a trySend call.
- val appliedChanges = Channel<Set<Any>>(Channel.UNLIMITED)
-
- // Register the apply observer before running for the first time
- // so that we don't miss updates.
- val unregisterApplyObserver = Snapshot.registerApplyObserver { changed, _ ->
- appliedChanges.trySend(changed)
- }
-
- try {
- var lastValue = Snapshot.takeSnapshot(readObserver).run {
- try {
- enter(block)
- } finally {
- dispose()
- }
- }
- emit(lastValue)
-
- while (true) {
- var found = false
- var changedObjects = appliedChanges.receive()
-
- // Poll for any other changes before running block to minimize the number of
- // additional times it runs for the same data
- while (true) {
- // Assumption: readSet will typically be smaller than changed
- found = found || readSet.intersects(changedObjects)
- changedObjects = appliedChanges.tryReceive().getOrNull() ?: break
- }
-
- if (found) {
- readSet.clear()
- val newValue = Snapshot.takeSnapshot(readObserver).run {
- try {
- enter(block)
- } finally {
- dispose()
- }
- }
-
- if (newValue != lastValue) {
- lastValue = newValue
- emit(newValue)
- }
- }
- }
- } finally {
- unregisterApplyObserver.dispose()
- }
-}
-
-/**
- * Return `true` if there are any elements shared between `this` and [other]
- */
-private fun <T> Set<T>.intersects(other: Set<T>): Boolean =
- if (size < other.size) any { it in other } else other.any { it in this }
\ No newline at end of file