diff --git a/lifecycle/lifecycle-livedata-ktx/api/current.txt b/lifecycle/lifecycle-livedata-ktx/api/current.txt index 152a448831f48..784f04e75ef55 100644 --- a/lifecycle/lifecycle-livedata-ktx/api/current.txt +++ b/lifecycle/lifecycle-livedata-ktx/api/current.txt @@ -22,9 +22,9 @@ package androidx.lifecycle { } public final class TransformationsKt { - method public static inline androidx.lifecycle.LiveData distinctUntilChanged(androidx.lifecycle.LiveData); - method public static inline androidx.lifecycle.LiveData map(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1 transform); - method public static inline androidx.lifecycle.LiveData switchMap(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1> transform); + method @CheckResult public static inline androidx.lifecycle.LiveData distinctUntilChanged(androidx.lifecycle.LiveData); + method @CheckResult public static inline androidx.lifecycle.LiveData map(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1 transform); + method @CheckResult public static inline androidx.lifecycle.LiveData switchMap(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1> transform); } } diff --git a/lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_current.txt b/lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_current.txt index 002fa4e8004c0..7b099da24f77c 100644 --- a/lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_current.txt +++ b/lifecycle/lifecycle-livedata-ktx/api/public_plus_experimental_current.txt @@ -22,9 +22,9 @@ package androidx.lifecycle { } public final class TransformationsKt { - method public static inline androidx.lifecycle.LiveData distinctUntilChanged(androidx.lifecycle.LiveData); - method public static inline androidx.lifecycle.LiveData map(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1 transform); - method public static inline androidx.lifecycle.LiveData switchMap(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1> transform); + method @CheckResult public static inline androidx.lifecycle.LiveData distinctUntilChanged(androidx.lifecycle.LiveData); + method @CheckResult public static inline androidx.lifecycle.LiveData map(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1 transform); + method @CheckResult public static inline androidx.lifecycle.LiveData switchMap(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1> transform); } } diff --git a/lifecycle/lifecycle-livedata-ktx/api/restricted_current.txt b/lifecycle/lifecycle-livedata-ktx/api/restricted_current.txt index 152a448831f48..784f04e75ef55 100644 --- a/lifecycle/lifecycle-livedata-ktx/api/restricted_current.txt +++ b/lifecycle/lifecycle-livedata-ktx/api/restricted_current.txt @@ -22,9 +22,9 @@ package androidx.lifecycle { } public final class TransformationsKt { - method public static inline androidx.lifecycle.LiveData distinctUntilChanged(androidx.lifecycle.LiveData); - method public static inline androidx.lifecycle.LiveData map(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1 transform); - method public static inline androidx.lifecycle.LiveData switchMap(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1> transform); + method @CheckResult public static inline androidx.lifecycle.LiveData distinctUntilChanged(androidx.lifecycle.LiveData); + method @CheckResult public static inline androidx.lifecycle.LiveData map(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1 transform); + method @CheckResult public static inline androidx.lifecycle.LiveData switchMap(androidx.lifecycle.LiveData, kotlin.jvm.functions.Function1> transform); } } diff --git a/lifecycle/lifecycle-livedata-ktx/src/main/java/androidx/lifecycle/Transformations.kt b/lifecycle/lifecycle-livedata-ktx/src/main/java/androidx/lifecycle/Transformations.kt index d3e8ae6992b4c..656d4b1d60cbd 100644 --- a/lifecycle/lifecycle-livedata-ktx/src/main/java/androidx/lifecycle/Transformations.kt +++ b/lifecycle/lifecycle-livedata-ktx/src/main/java/androidx/lifecycle/Transformations.kt @@ -16,6 +16,8 @@ package androidx.lifecycle +import androidx.annotation.CheckResult + /** * Returns a [LiveData] mapped from `this` LiveData by applying [transform] to each value set on * `this` LiveData. @@ -32,6 +34,7 @@ package androidx.lifecycle * val userFullNameLD: LiveData = userLD.map { user -> user.firstName + user.lastName } * ``` */ +@CheckResult public inline fun LiveData.map(crossinline transform: (X) -> Y): LiveData = Transformations.map(this) { transform(it) } @@ -74,6 +77,7 @@ public inline fun LiveData.map(crossinline transform: (X) -> Y): LiveD * } * ``` */ +@CheckResult public inline fun LiveData.switchMap( crossinline transform: (X) -> LiveData ): LiveData = Transformations.switchMap(this) { transform(it) } @@ -82,6 +86,7 @@ public inline fun LiveData.switchMap( * Creates a new [LiveData] object does not emit a value until the source `this` LiveData value * has been changed. The value is considered changed if `equals()` yields `false`. */ +@CheckResult @Suppress("NOTHING_TO_INLINE") public inline fun LiveData.distinctUntilChanged(): LiveData = Transformations.distinctUntilChanged(this)