Skip to content

Commit

Permalink
Merge pull request #35 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.4.5
  • Loading branch information
Alex009 authored May 21, 2021
2 parents 279f807 + 947d25e commit d49ef34
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
}
```

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Pagination<Item>(
override val coroutineContext: CoroutineContext = parentScope.coroutineContext

private val mStateStorage =
MutableLiveData<ResourceState<List<Item>, Throwable>>(initValue.asStateNullIsEmpty())
MutableLiveData<ResourceState<List<Item>, Throwable>>(initValue.asStateNullIsLoading())

val state = mStateStorage.readOnly()

Expand Down Expand Up @@ -161,8 +161,12 @@ class Pagination<Item>(
}
}

fun <T, E> T?.asStateNullIsEmpty() = asState {
ResourceState.Loading<T, E>()
fun <T, E> List<T>?.asStateNullIsEmpty() = asState {
ResourceState.Empty<List<T>, E>()
}

fun <T, E> List<T>?.asStateNullIsLoading() = asState {
ResourceState.Loading<List<T>, E>()
}

interface IdEntity {
Expand Down

0 comments on commit d49ef34

Please sign in to comment.