Skip to content

Commit 937c050

Browse files
committed
feat(add-new-user)
1 parent ae71fc9 commit 937c050

File tree

19 files changed

+441
-69
lines changed

19 files changed

+441
-69
lines changed

app/src/main/java/com/hoc/flowmvi/core/DefaultCoroutineDispatchers.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ import javax.inject.Inject
88
internal class DefaultCoroutineDispatchers @Inject constructor() : AppCoroutineDispatchers {
99
override val main: CoroutineDispatcher get() = Dispatchers.Main
1010
override val io: CoroutineDispatcher get() = Dispatchers.IO
11-
override val mainImmediate: CoroutineDispatcher get() = Dispatchers.Main.immediate
1211
override val default: CoroutineDispatcher get() = Dispatchers.Default
1312
}

buildSrc/src/main/kotlin/deps.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ inline val PDsS.androidLib: PDS get() = id("com.android.library")
130130
inline val PDsS.kotlinAndroid: PDS get() = kotlin("android")
131131
inline val PDsS.kotlin: PDS get() = kotlin("jvm")
132132
inline val PDsS.kotlinKapt: PDS get() = kotlin("kapt")
133+
inline val PDsS.kotlinParcelize: PDS get() = id("kotlin-parcelize")
133134
inline val PDsS.daggerHiltAndroid: PDS get() = id("dagger.hilt.android.plugin")
134135

135136
inline val DependencyHandler.domain get() = project(":domain")
@@ -144,7 +145,9 @@ inline val DependencyHandler.mviBase get() = project(":mvi-base")
144145
inline val DependencyHandler.mviTesting get() = project(":mvi-testing")
145146
inline val DependencyHandler.testUtils get() = project(":test-utils")
146147

147-
fun DependencyHandler.implementationCompose() {
148+
fun DependencyHandler.implementationCompose(
149+
includeMaterial2: Boolean = false,
150+
) {
148151
arrayOf(
149152
platform(deps.compose.bom),
150153
// activity compose
@@ -160,7 +163,10 @@ fun DependencyHandler.implementationCompose() {
160163
deps.compose.layout,
161164
deps.compose.foundation,
162165
deps.compose.ui,
163-
deps.compose.material,
166+
*(
167+
if (includeMaterial2) arrayOf(deps.compose.material)
168+
else emptyArray()
169+
),
164170
deps.compose.material3,
165171
deps.compose.materialIconsExtended,
166172
deps.compose.runtime,

core-ui/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@ dependencies {
4444
implementation(deps.lifecycle.runtimeKtx)
4545
implementation(deps.androidx.material)
4646

47+
implementation(deps.coroutines.core)
48+
implementation(deps.coroutines.android)
49+
4750
addUnitTest()
4851
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.hoc.flowmvi.core_ui
2+
3+
import android.util.Log
4+
import kotlinx.coroutines.Dispatchers
5+
import kotlinx.coroutines.currentCoroutineContext
6+
import kotlin.coroutines.ContinuationInterceptor
7+
8+
suspend fun debugCheckImmediateMainDispatcher() {
9+
if (BuildConfig.DEBUG) {
10+
val interceptor = currentCoroutineContext()[ContinuationInterceptor]
11+
Log.d(
12+
"###",
13+
"debugCheckImmediateMainDispatcher: $interceptor, ${Dispatchers.Main.immediate}, ${Dispatchers.Main}"
14+
)
15+
16+
check(interceptor === Dispatchers.Main.immediate) {
17+
"Expected ContinuationInterceptor to be Dispatchers.Main.immediate but was $interceptor"
18+
}
19+
}
20+
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import androidx.lifecycle.Lifecycle
88
import androidx.lifecycle.flowWithLifecycle
99
import androidx.lifecycle.repeatOnLifecycle
1010
import kotlinx.coroutines.CoroutineScope
11+
import kotlinx.coroutines.Dispatchers
1112
import kotlinx.coroutines.flow.Flow
13+
import kotlinx.coroutines.withContext
1214

1315
@Composable
1416
fun <T> rememberFlowWithLifecycle(
@@ -32,8 +34,10 @@ fun <T> Flow<T>.collectInLaunchedEffectWithLifecycle(
3234
) {
3335
val flow = this
3436
LaunchedEffect(flow, lifecycle, minActiveState, *keys) {
35-
lifecycle.repeatOnLifecycle(minActiveState) {
36-
flow.collect { collector(it) }
37+
withContext(Dispatchers.Main.immediate) {
38+
lifecycle.repeatOnLifecycle(minActiveState) {
39+
flow.collect { collector(it) }
40+
}
3741
}
3842
}
3943
}

core/src/main/java/com/hoc/flowmvi/core/dispatchers/AppCoroutineDispatchers.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ import kotlinx.coroutines.CoroutineDispatcher
55
interface AppCoroutineDispatchers {
66
val main: CoroutineDispatcher
77
val io: CoroutineDispatcher
8-
val mainImmediate: CoroutineDispatcher
98
val default: CoroutineDispatcher
109
}

data/src/test/java/com/hoc/flowmvi/data/UserRepositoryImplRealAPITest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class UserRepositoryImplRealAPITest : KoinTest {
3838
object : AppCoroutineDispatchers {
3939
override val main: CoroutineDispatcher get() = Main
4040
override val io: CoroutineDispatcher get() = IO
41-
override val mainImmediate: CoroutineDispatcher get() = Main.immediate
4241
override val default: CoroutineDispatcher get() = IO
4342
}
4443
}

feature-add/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
androidLib
33
kotlinAndroid
44
kotlinKapt
5+
kotlinParcelize
56
daggerHiltAndroid
67
}
78

@@ -62,7 +63,9 @@ dependencies {
6263

6364
implementation(deps.androidx.material)
6465

66+
implementation(deps.arrow.core)
6567
implementation(deps.coroutines.core)
68+
implementation(deps.flowExt)
6669

6770
implementation(deps.daggerHilt.android)
6871
kapt(deps.daggerHilt.compiler)
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.hoc.flowmvi.ui.add">
4-
5-
<application>
6-
7-
<activity
8-
android:name=".AddActivity"
9-
android:label="Add user" />
10-
11-
</application>
12-
13-
</manifest>
2+
<manifest package="com.hoc.flowmvi.ui.add" />

feature-add/src/main/java/com/hoc/flowmvi/ui/add/AddActivity.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)