From 058c2d2c397c7c9ee75b5463371f60fd23708ee3 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Fri, 21 May 2021 14:05:10 +0700 Subject: [PATCH 1/2] #33 asStateNullIsEmpty return EmptyState on null and emptyList now --- .../kotlin/dev/icerock/moko/paging/Pagination.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/paging/src/commonMain/kotlin/dev/icerock/moko/paging/Pagination.kt b/paging/src/commonMain/kotlin/dev/icerock/moko/paging/Pagination.kt index bd5cbf8..aca645f 100644 --- a/paging/src/commonMain/kotlin/dev/icerock/moko/paging/Pagination.kt +++ b/paging/src/commonMain/kotlin/dev/icerock/moko/paging/Pagination.kt @@ -25,7 +25,7 @@ class Pagination( override val coroutineContext: CoroutineContext = parentScope.coroutineContext private val mStateStorage = - MutableLiveData, Throwable>>(initValue.asStateNullIsEmpty()) + MutableLiveData, Throwable>>(initValue.asStateNullIsLoading()) val state = mStateStorage.readOnly() @@ -161,8 +161,12 @@ class Pagination( } } -fun T?.asStateNullIsEmpty() = asState { - ResourceState.Loading() +fun List?.asStateNullIsEmpty() = asState { + ResourceState.Empty, E>() +} + +fun List?.asStateNullIsLoading() = asState { + ResourceState.Loading, E>() } interface IdEntity { From dff4762de98be25111fa89b67616a73935c3fbb7 Mon Sep 17 00:00:00 2001 From: Anton Shestak Date: Fri, 21 May 2021 14:06:07 +0700 Subject: [PATCH 2/2] #33 updated version --- README.md | 3 ++- buildSrc/src/main/kotlin/Deps.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d8c0f8..23f96db 100755 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ This is a Kotlin MultiPlatform library that contains pagination logic for kotlin ### mavenCentral - kotlin 1.4.31 - 0.4.4 + - 0.4.5 ## Installation root build.gradle @@ -59,7 +60,7 @@ allprojects { project build.gradle ```groovy dependencies { - commonMainApi("dev.icerock.moko:paging:0.4.4") + commonMainApi("dev.icerock.moko:paging:0.4.5") } ``` diff --git a/buildSrc/src/main/kotlin/Deps.kt b/buildSrc/src/main/kotlin/Deps.kt index e1dc9a2..4cfc6cd 100755 --- a/buildSrc/src/main/kotlin/Deps.kt +++ b/buildSrc/src/main/kotlin/Deps.kt @@ -18,7 +18,7 @@ object Deps { private const val mokoMvvmVersion = "0.9.2" private const val mokoResourcesVersion = "0.15.1" private const val mokoUnitsVersion = "0.4.2" - const val mokoPagingVersion = "0.4.4" + const val mokoPagingVersion = "0.4.5" object Android { const val compileSdk = 28