Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f70107e

Browse files
Merge pull request #285 from Kotlin-Android-Open-Source/tweaks
This pull request implements a comprehensive refactoring that renames the `getUsers` method and related use cases to `observeUsers` to better reflect the flow-based observable nature of the functionality. The changes also include code style improvements, dependency updates, and minor optimizations. Key changes: - Renamed `getUsers` to `observeUsers` across the entire codebase including repositories, use cases, tests, and ViewModels - Updated various code style elements including constant naming conventions and coroutine dispatcher handling - Added performance optimizations and removed unused logging statements
2 parents 944d925 + f9443f3 commit f70107e

File tree

20 files changed

+89
-56
lines changed

20 files changed

+89
-56
lines changed

‎.idea/codeStyles/Project.xml‎

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

‎.idea/compiler.xml‎

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

‎.idea/kotlinc.xml‎

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

‎.idea/misc.xml‎

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

‎LICENSE‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019-2024 Kotlin Android Open Source
3+
Copyright (c) 2019-2025 Kotlin Android Open Source
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
59 Bytes
Binary file not shown.

‎core-ui/src/main/java/com/hoc/flowmvi/core_ui/CollectIn.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import kotlinx.coroutines.Job
99
import kotlinx.coroutines.flow.Flow
1010
import kotlinx.coroutines.flow.collect
1111
import kotlinx.coroutines.launch
12-
import timber.log.Timber
1312

1413
inline fun <T> Flow<T>.collectIn(
1514
owner: LifecycleOwner,
@@ -18,7 +17,6 @@ inline fun <T> Flow<T>.collectIn(
1817
): Job =
1918
owner.lifecycleScope.launch {
2019
owner.repeatOnLifecycle(state = minActiveState) {
21-
Timber.d("Start collecting $owner $minActiveState...")
2220
collect { action(it) }
2321
}
2422
}
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package com.hoc.flowmvi.core_ui
22

3-
import kotlin.coroutines.ContinuationInterceptor
3+
import kotlinx.coroutines.CoroutineDispatcher
44
import kotlinx.coroutines.Dispatchers
55
import kotlinx.coroutines.currentCoroutineContext
66
import timber.log.Timber
77

8-
suspend fun debugCheckImmediateMainDispatcher() {
8+
@OptIn(ExperimentalStdlibApi::class)
9+
suspend inline fun debugCheckImmediateMainDispatcher() {
910
if (BuildConfig.DEBUG) {
10-
val interceptor = currentCoroutineContext()[ContinuationInterceptor]
11-
Timber.d("debugCheckImmediateMainDispatcher: interceptor=$interceptor")
11+
val dispatcher = checkNotNull(currentCoroutineContext()[CoroutineDispatcher]) {
12+
"Expected CoroutineDispatcher in current CoroutineContext but was null"
13+
}.also { Timber.d("debugCheckImmediateMainDispatcher: dispatcher=$it") }
1214

13-
check(interceptor === Dispatchers.Main.immediate) {
14-
"Expected ContinuationInterceptor to be Dispatchers.Main.immediate but was $interceptor"
15+
check(
16+
dispatcher === Dispatchers.Main.immediate ||
17+
!dispatcher.isDispatchNeeded(Dispatchers.Main.immediate),
18+
) {
19+
"Expected dispatcher to be Dispatchers.Main.immediate but was $dispatcher"
1520
}
1621
}
1722
}

‎core/src/main/java/com/hoc/flowmvi/core/selfReference.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import kotlin.reflect.KProperty
1111
value class SelfReference<T>(
1212
val value: T,
1313
) : ReadOnlyProperty<Any?, T> {
14-
override fun getValue(
14+
@Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
15+
override inline fun getValue(
1516
thisRef: Any?,
1617
property: KProperty<*>,
1718
): T = value

‎data/src/main/java/com/hoc/flowmvi/data/UserRepositoryImpl.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal class UserRepositoryImpl(
8080
.first()
8181

8282
@OptIn(FlowExtPreview::class)
83-
override fun getUsers() =
83+
override fun observeUsers() =
8484
changesFlow
8585
.onEach { Timber.d("[USER_REPO] Change=$it") }
8686
.scanWith(::getUsersFromRemoteWithRetry) { acc, change ->

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /