Skip to content

Commit 4791c1f

Browse files
committed
LiveData post error as well as data if has
1 parent cf255d8 commit 4791c1f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/src/main/java/me/li2/android/common/arch/LiveDataExt.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* https://github.com/li2
44
*/
55
@file:Suppress("unused")
6+
67
package me.li2.android.common.arch
78

89
import androidx.fragment.app.Fragment
@@ -17,7 +18,7 @@ fun <T> MutableLiveData<Resource<T>>.postLoading() =
1718
postValue(Resource.loading(value?.data))
1819

1920
fun <T> MutableLiveData<Resource<T>>.postError(exception: Exception? = null) =
20-
postValue(Resource.error(exception))
21+
postValue(Resource.error(exception, value?.data))
2122

2223
fun <T : Any, L : LiveData<T>> Fragment.observeOnView(liveData: L, body: (T) -> Unit) {
2324
liveData.observe(viewLifecycleOwner, Observer(body))

0 commit comments

Comments
 (0)