Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#39 add test, flow, core modules + up version #60

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

kramlex
Copy link

@kramlex kramlex commented Jun 3, 2022

No description provided.

}

dependencies {
commonMainImplementation(libs.coroutines)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api dependency. we have CoroutineScope in constructor

Comment on lines 42 to 45
abstract suspend fun loadFirstPageSuspend()
abstract suspend fun loadNextPageSuspend()
abstract suspend fun refreshSuspend()
abstract suspend fun setDataSuspend(items: List<Item>?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be abstract - it should be implemented here, in core.
abstract should be only protected methods for set/get data in state.

}

kotlin {
jvm()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something wrong with format

Comment on lines 38 to 44
): StateFlow<List<T>> = combine(this, loading) { items, nextPageLoading ->
if (nextPageLoading) {
items + itemFactory()
} else {
items
}
}.stateIn(parentScope, SharingStarted.Lazily, emptyList())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why duplication?

this.withLoadingItem(loading, itemFactory).stateIn(..)

Comment on lines 46 to 51
fun <T> Flow<List<T>>.stateWithReachEndNotifier(
parentScope: CoroutineScope,
action: (Int) -> Unit
): StateFlow<ReachEndNotifierList<T>> = map { list ->
list.withReachEndNotifier(action)
}.stateIn(parentScope, SharingStarted.Lazily, ReachEndNotifierList(emptyList(), action))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove duplication

import kotlinx.coroutines.launch
import kotlin.test.Test

class IntegrationTests : BaseTestsClass() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find way to reuse tests code between livedata and flow implementation


private var loadNextPageDeferred: Deferred<List<Item>>? = null

fun loadFirstPage() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it's removed?


package dev.icerock.moko.paging.state

sealed interface PagingDataState<T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it's implemented in #59 issue? we can't add flow without it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


typealias ResourceStateThrow<T> = ResourceState<T, Throwable>

sealed interface ResourceState<out T, out E> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplication of moko-mvvm-state is bad =_=

Copy link
Author

@kramlex kramlex Jun 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mvvm-state depends on moko-livedata

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so we should extract livedata dependency from mvvm-state...we will have mvvm-state, mvvm-state-livedata, mvvm-state-flow

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I use these changes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, if you can do this comment - icerockdev/moko-mvvm#152 (comment)

androidMainApi(libs.androidCoreTesting)
commonMainApi(libs.ktorClient)
commonMainApi(libs.ktorClientMock)
iosX64MainApi(libs.coroutines)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coroutines already added

val result: Result<T>? = expectation.wait()
if (result == null) throw RuntimeException("runBlocking failed")
val result: Result<T> = expectation.wait()
?: throw RuntimeException("runBlocking failed")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TooGenericExceptionThrown: RuntimeException is a too generic Exception. Prefer throwing specific exceptions that indicate a specific error case.

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@sonarcloud
Copy link

sonarcloud bot commented Jun 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can we have flow instead of liveData for state Add support for working with kotlinx.coroutines
2 participants