Skip to content

Commit 3b015dd

Browse files
committed
Refactor: Change live data utils map nullable mapper lambda signature
This change removes the need to have this double exclamation ('!!') added on the 'mapNullable(...)' extension function for 'LiveData', but that change updates this extension function signature nonetheless. However, the client classes that are using this 'mapNullable(...)' extension function doesn't seem to be affected in any way, which makes this change look safe, at least as far as it was tested, via unit, UI and manual testing. For completeness and visibility purposes, below are those client classes: 1) [StatsViewAllViewModel] Via the 'dateSelectorData' field. 2) [StatsViewModel] Via the 'toolbarHasShadow' field. 3) [StatsListViewModel] Via the 'dateSelectorData' field. 4) [WPMainActivityViewModel] Via the 'onFocusPointVisibilityChange' field.
1 parent eefb94b commit 3b015dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

WordPress/src/main/java/org/wordpress/android/util/LiveDataUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ fun <T> LiveData<T>.perform(block: LiveData<T>.(T) -> Unit): LiveData<T> {
341341
/**
342342
* Simple wrapper of the map utility method that is null safe
343343
*/
344-
fun <T, U> LiveData<T>.mapNullable(mapper: (T?) -> U?): LiveData<U> {
345-
return this.map { mapper(it)!! }
344+
fun <T, U> LiveData<T>.mapNullable(mapper: (T?) -> U): LiveData<U> {
345+
return this.map { mapper(it) }
346346
}
347347

348348
/**

0 commit comments

Comments
 (0)