Skip to content

Commit

Permalink
Merge pull request #38 from sczerwinski/feature/lifecycle-livedata-ktx
Browse files Browse the repository at this point in the history
Upgrade lifecycle-livedata-ktx to 2.3.0
  • Loading branch information
sczerwinski authored Feb 11, 2021
2 parents 4708b87 + f434f05 commit 3d14ae6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## [Unreleased]
### Changed
- Upgrade Gradle to 6.8.2
- Upgrade Gradle to `6.8.2`
- Dependencies:
- Upgrade `android-junit5` to `1.7.1.1`
- Upgrade `lifecycle-livedata-ktx` to `2.3.0`

## [1.1.0-RC1]
### Changed
- Upgrade Gradle to 6.8
- Upgrade Gradle to `6.8`
- Dependencies:
- Upgrade Kotlin to `1.4.30`
- Upgrade Android Gradle Plugin to `4.1.2`
Expand Down
2 changes: 1 addition & 1 deletion lifecycle/livedata-test-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
}

dependencies {
api("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
api("androidx.lifecycle:lifecycle-livedata-ktx:2.3.0")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1")
Expand Down
2 changes: 1 addition & 1 deletion lifecycle/livedata/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
}

dependencies {
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.2.0")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.0")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.1")
Expand Down
2 changes: 2 additions & 0 deletions lifecycle/livedata/src/main/java/DefaultIfEmpty.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@

package it.czerwinski.android.lifecycle.livedata

import android.annotation.SuppressLint
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData

/**
* Returns a [LiveData] that emits the values emitted by this LiveData or a specified default value if this LiveData has
* not yet emitted any values at the time of observing.
*/
@SuppressLint("NullSafeMutableLiveData") // defaultValue can only be null if T is nullable
fun <T> LiveData<T>.defaultIfEmpty(defaultValue: T): LiveData<T> {
val result = MediatorLiveData<T>()
val observer = DistinguishedFirstTimeObserver<T>(
Expand Down
2 changes: 2 additions & 0 deletions lifecycle/livedata/src/main/java/Map.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package it.czerwinski.android.lifecycle.livedata

import android.annotation.SuppressLint
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData

Expand All @@ -32,6 +33,7 @@ import androidx.lifecycle.MediatorLiveData
* val userLiveData: LiveData<User> = userOptionLiveData.mapNotNull { user -> user.getOrNull() }
* ```
*/
@SuppressLint("NullSafeMutableLiveData") // After null check
fun <T, R> LiveData<T>.mapNotNull(
transform: (T) -> R?
): LiveData<R> {
Expand Down

0 comments on commit 3d14ae6

Please sign in to comment.