Skip to content

Commit

Permalink
Merge pull request #25 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.4.2
  • Loading branch information
Alex009 authored Jan 19, 2021
2 parents e9eb532 + 632e591 commit e4e60f0
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 24 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This is a Kotlin MultiPlatform library that contains pagination logic for kotlin
- 0.4.0
- kotlin 1.4.21
- 0.4.1
- 0.4.2

## Installation
root build.gradle
Expand All @@ -53,7 +54,7 @@ allprojects {
project build.gradle
```groovy
dependencies {
commonMainApi("dev.icerock.moko:paging:0.4.1")
commonMainApi("dev.icerock.moko:paging:0.4.2")
}
```

Expand Down Expand Up @@ -110,7 +111,7 @@ Observing **Pagination** states:

```kotlin
// Observing the state of the pagination
pagination.state.addObserver { state: State<List<ItemClass>, Throwable> ->
pagination.state.addObserver { state: ResourceState<List<ItemClass>, Throwable> ->
// ...
}

Expand Down
8 changes: 5 additions & 3 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ object Deps {

private const val ktorClientVersion = "1.4.0"
private const val coroutinesVersion = "1.4.2-native-mt"
private const val mokoMvvmVersion = "0.8.1"
private const val mokoMvvmVersion = "0.9.0"
private const val mokoResourcesVersion = "0.13.2"
private const val mokoUnitsVersion = "0.4.0"
const val mokoPagingVersion = "0.4.1"
const val mokoPagingVersion = "0.4.2"

object Android {
const val compileSdk = 28
Expand Down Expand Up @@ -76,7 +76,9 @@ object Deps {
"dev.icerock.moko:resources:$mokoResourcesVersion"
val mokoUnits = "dev.icerock.moko:units:$mokoUnitsVersion"
.defaultMPL(ios = true)
val mokoMvvm = "dev.icerock.moko:mvvm:$mokoMvvmVersion"
val mokoMvvmLiveData = "dev.icerock.moko:mvvm-livedata:$mokoMvvmVersion"
.defaultMPL(ios = true)
val mokoMvvmState = "dev.icerock.moko:mvvm-state:$mokoMvvmVersion"
.defaultMPL(ios = true)
const val mokoPaging = "dev.icerock.moko:paging:$mokoPagingVersion"
}
Expand Down
3 changes: 2 additions & 1 deletion paging/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ version = Deps.mokoPagingVersion

dependencies {
commonMainImplementation(Deps.Libs.MultiPlatform.coroutines)
commonMainImplementation(Deps.Libs.MultiPlatform.mokoMvvm.common)
commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmLiveData.common)
commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmState.common)

androidMainImplementation(Deps.Libs.Android.appCompat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package dev.icerock.moko.paging

import dev.icerock.moko.mvvm.State
import dev.icerock.moko.mvvm.ResourceState
import dev.icerock.moko.mvvm.asState
import dev.icerock.moko.mvvm.livedata.MutableLiveData
import dev.icerock.moko.mvvm.livedata.readOnly
Expand All @@ -25,7 +25,7 @@ class Pagination<Item>(
override val coroutineContext: CoroutineContext = parentScope.coroutineContext

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

val state = mStateStorage.readOnly()

Expand Down Expand Up @@ -56,7 +56,7 @@ class Pagination<Item>(
val items: List<Item> = dataSource.loadPage(null)
mStateStorage.value = items.asState()
} catch (error: Throwable) {
mStateStorage.value = State.Error(error)
mStateStorage.value = ResourceState.Failed(error)
}
listMutex.unlock()
}
Expand Down Expand Up @@ -137,7 +137,7 @@ class Pagination<Item>(
// notify
refreshListener(Result.success(items))
} catch (error: Throwable) {
mStateStorage.value = State.Error(error)
mStateStorage.value = ResourceState.Failed(error)
// flag
mRefreshLoading.value = false
// notify
Expand All @@ -161,7 +161,7 @@ class Pagination<Item>(
}

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

interface IdEntity {
Expand Down
2 changes: 1 addition & 1 deletion sample/ios-app/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ target 'TestProj' do
# MultiPlatformLibrary
pod 'MultiPlatformLibrary', :path => '../mpp-library'

pod 'MultiPlatformLibraryUnits', :git => 'https://github.com/icerockdev/moko-units.git', :tag => 'release/0.2.2'
pod 'MultiPlatformLibraryUnits', :git => 'https://github.com/icerockdev/moko-units.git', :tag => 'release/0.4.0'
end
16 changes: 8 additions & 8 deletions sample/ios-app/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
PODS:
- MultiPlatformLibrary (0.1.0)
- MultiPlatformLibraryUnits (0.1.0):
- MultiPlatformLibraryUnits (0.4.0):
- MultiPlatformLibrary
- MultiPlatformLibraryUnits/Core (= 0.1.0)
- MultiPlatformLibraryUnits/Core (0.1.0):
- MultiPlatformLibraryUnits/Core (= 0.4.0)
- MultiPlatformLibraryUnits/Core (0.4.0):
- MultiPlatformLibrary

DEPENDENCIES:
- MultiPlatformLibrary (from `../mpp-library`)
- MultiPlatformLibraryUnits (from `https://github.com/icerockdev/moko-units.git`, tag `release/0.2.2`)
- MultiPlatformLibraryUnits (from `https://github.com/icerockdev/moko-units.git`, tag `release/0.4.0`)

EXTERNAL SOURCES:
MultiPlatformLibrary:
:path: "../mpp-library"
MultiPlatformLibraryUnits:
:git: https://github.com/icerockdev/moko-units.git
:tag: release/0.2.2
:tag: release/0.4.0

CHECKOUT OPTIONS:
MultiPlatformLibraryUnits:
:git: https://github.com/icerockdev/moko-units.git
:tag: release/0.2.2
:tag: release/0.4.0

SPEC CHECKSUMS:
MultiPlatformLibrary: 176fb8ade516666cd47e93de1b71ba0441a541bb
MultiPlatformLibraryUnits: f4fe5d26427bb3c996a6d786d9cc7552bc4ae8cb
MultiPlatformLibraryUnits: 0d2efb66522f63a8b38d5639d329aeb70cd4e9ba

PODFILE CHECKSUM: 295de1c18af3cf808bbd87a8b0b801e86d8349f4
PODFILE CHECKSUM: ef522d3d1655c544774fcadd6504f1f42278f721

COCOAPODS: 1.9.3
6 changes: 4 additions & 2 deletions sample/mpp-library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ dependencies {

commonMainApi(Deps.Libs.MultiPlatform.mokoPaging)
commonMainApi(Deps.Libs.MultiPlatform.mokoUnits.common)
commonMainApi(Deps.Libs.MultiPlatform.mokoMvvm.common)
commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmLiveData.common)
commonMainApi(Deps.Libs.MultiPlatform.mokoMvvmState.common)
commonMainApi(Deps.Libs.MultiPlatform.mokoResources)

androidMainImplementation(Deps.Libs.Android.lifecycle)
}

framework {
export(Deps.Libs.MultiPlatform.mokoUnits)
export(Deps.Libs.MultiPlatform.mokoMvvm)
export(Deps.Libs.MultiPlatform.mokoMvvmLiveData)
export(Deps.Libs.MultiPlatform.mokoMvvmState)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package com.icerockdev.library

import dev.icerock.moko.mvvm.State
import dev.icerock.moko.mvvm.ResourceState
import dev.icerock.moko.mvvm.livedata.LiveData
import dev.icerock.moko.mvvm.livedata.dataTransform
import dev.icerock.moko.mvvm.livedata.errorTransform
Expand Down Expand Up @@ -37,7 +37,7 @@ class ListViewModel(
)

val isRefreshing: LiveData<Boolean> = pagination.refreshLoading
val state: LiveData<State<List<TableUnitItem>, String>> = pagination.state
val state: LiveData<ResourceState<List<TableUnitItem>, String>> = pagination.state
.dataTransform {
map { productList ->
productList.map { product ->
Expand Down

0 comments on commit e4e60f0

Please sign in to comment.