Skip to content

Commit 4caa18b

Browse files
author
Pablo Orgaz
committed
Split RX/Flow, add Incremental compilation support
1 parent d31d81d commit 4caa18b

File tree

343 files changed

+1807
-64
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+1807
-64
lines changed

app/src/main/java/org/sample/SampleActivity.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import kotlinx.android.synthetic.main.home_activity.*
88
import mini.Action
99
import mini.LoggerInterceptor
1010
import mini.MiniGen
11+
import mini.Reducer
1112
import mini.Store
1213

1314
class SampleActivity : FluxActivity() {
@@ -45,4 +46,10 @@ interface ActionInterface {
4546
class ActionTwo(override val text: String) : ActionInterface
4647

4748
data class DummyState(val text: String = "dummy")
48-
class DummyStore : Store<DummyState>()
49+
class DummyStore : Store<DummyState>() {
50+
51+
@Reducer
52+
fun hello(action: ActionInterface) {
53+
54+
}
55+
}

build.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
apply plugin: 'maven-publish'
2+
13
buildscript {
24
ext {
35
kotlin_version = "1.3.50"
4-
mini_version = "4.0.5"
6+
mini_version = "4.1.0"
57
}
68

79
repositories {
@@ -29,7 +31,3 @@ allprojects {
2931
google()
3032
}
3133
}
32-
33-
task clean(type: Delete) {
34-
delete rootProject.buildDir
35-
}

mini-android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: "com.github.dcendents.android-maven"
44

55
android {
66
compileSdkVersion 29
7-
buildToolsVersion "29.0.0"
7+
buildToolsVersion "29.0.2"
88

99
defaultConfig {
1010
minSdkVersion 14
@@ -25,9 +25,9 @@ dependencies {
2525
implementation fileTree(dir: "libs", include: ["*.jar"])
2626
api project(":mini-common")
2727

28-
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1"
29-
api "androidx.appcompat:appcompat:1.0.2"
30-
api "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha02"
28+
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
29+
api "androidx.appcompat:appcompat:1.1.0"
30+
api "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0-alpha05"
3131

3232
testImplementation "junit:junit:4.12"
3333
androidTestImplementation "androidx.test:runner:1.2.0"

mini-common/build.gradle

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,11 @@
1-
apply plugin: 'kotlin'
1+
apply plugin: "kotlin"
22
apply from: "../jitpack.gradle"
33

44
dependencies {
5-
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6-
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
7-
8-
//Optional Rx and Android bindings, one day these should be modules,
9-
//for now we compile against them but let user package library
5+
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6+
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
107
compileOnly "com.google.android:android:4.1.1.4"
118

12-
def coroutines = "1.3.0-RC"
13-
compileOnly "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
14-
testCompile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
15-
16-
def rx = "2.2.6"
17-
compileOnly "io.reactivex.rxjava2:rxjava:$rx"
18-
testCompile "io.reactivex.rxjava2:rxjava:$rx"
19-
20-
testCompile 'junit:junit:4.12'
9+
testImplementation "junit:junit:4.12"
2110
testImplementation "org.amshove.kluent:kluent:1.44"
22-
}
23-
24-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
25-
kotlinOptions.freeCompilerArgs += [
26-
"-Xuse-experimental=kotlin.Experimental",
27-
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
28-
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
29-
]
30-
}
31-
32-
apply plugin: 'idea'
33-
34-
idea {
35-
module {
36-
sourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
37-
generatedSourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
38-
}
3911
}

mini-common/src/main/java/mini/LoggerInterceptor.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package mini
22

3-
import kotlinx.coroutines.GlobalScope
4-
import kotlinx.coroutines.asCoroutineDispatcher
5-
import kotlinx.coroutines.launch
63
import java.util.concurrent.Executors
74
import kotlin.math.min
85

96
/** Actions implementing this interface won't log anything */
10-
@Action interface SilentAction
7+
@Action
8+
interface SilentAction
119

1210
class LoggerInterceptor constructor(stores: Collection<Store<*>>,
1311
private val logFn: (tag: String, msg: String) -> Unit,
1412
private val logInBackground: Boolean = false,
1513
private val tag: String = "MiniLog") : Interceptor {
1614

17-
private val coroutineDispatcher by lazy { Executors.newSingleThreadExecutor().asCoroutineDispatcher() }
15+
private val executor by lazy { Executors.newSingleThreadExecutor() }
1816
private val stores = stores.toList()
1917
private var lastActionTime = System.currentTimeMillis()
2018
private var actionCounter: Long = 0
@@ -41,8 +39,8 @@ class LoggerInterceptor constructor(stores: Collection<Store<*>>,
4139
sb.append('\n')
4240
sb.append("┌────────────────────────────────────────────\n")
4341
sb.append(String.format("├─> %s %dms [+%dms][%d] - %s",
44-
action.javaClass.simpleName, processTime, timeSinceLastAction, actionCounter % 10, action))
45-
.append("\n")
42+
action.javaClass.simpleName, processTime, timeSinceLastAction, actionCounter % 10, action))
43+
.append("\n")
4644

4745
for (i in beforeStates.indices) {
4846
val oldState = beforeStates[i]
@@ -58,9 +56,7 @@ class LoggerInterceptor constructor(stores: Collection<Store<*>>,
5856
}
5957

6058
if (logInBackground) {
61-
GlobalScope.launch(coroutineDispatcher) {
62-
logRunnable.run()
63-
}
59+
executor.submit(logRunnable)
6460
} else {
6561
logRunnable.run()
6662
}

mini-flow/build.gradle

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apply plugin: "kotlin"
2+
apply from: "../jitpack.gradle"
3+
4+
dependencies {
5+
implementation project(":mini-common")
6+
7+
def coroutines = "1.3.0"
8+
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
9+
10+
testImplementation "junit:junit:4.12"
11+
testImplementation "org.amshove.kluent:kluent:1.44"
12+
}
13+
14+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
15+
kotlinOptions.freeCompilerArgs += [
16+
"-Xuse-experimental=kotlin.Experimental",
17+
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
18+
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
19+
]
20+
}
Binary file not shown.
Binary file not shown.
31 Bytes
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)