diff --git a/dependencies.gradle b/dependencies.gradle
index 74e0407d9..a0f3c66ce 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -3,6 +3,7 @@ ext {
androidTestVersion = "1.4.0"
androidJUnitVersion = "1.1.0"
lifecycleVersion = '2.2.0'
+ lifecycleKtxVersion = '2.4.0-alpha03'
espressoVersion = "3.4.0"
junitVersion = "4.13.2"
@@ -12,6 +13,7 @@ ext {
robolectricVersion = "4.6.1"
truthVersion = "1.1.3"
composeVersion = "1.0.1"
+ kotlinCoroutinesVersion = "1.5.2"
libraries = [
androidx : [
@@ -22,7 +24,8 @@ ext {
ktx: "androidx.core:core-ktx:1.6.0"
],
activity : [
- compose : "androidx.activity:activity-compose:1.3.1"
+ compose : "androidx.activity:activity-compose:1.3.1",
+ ktx : "androidx.activity:activity-ktx:1.3.1"
],
compose : [
foundation : "androidx.compose.foundation:foundation:$composeVersion",
@@ -38,7 +41,9 @@ ext {
constraintlayout: "androidx.constraintlayout:constraintlayout:2.1.0",
lifecycle : [
runtime : "androidx.lifecycle:lifecycle-runtime:$lifecycleVersion",
- extensions: "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
+ extensions: "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion",
+ runtimektx : "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleKtxVersion",
+ extensionsktx: "androidx.lifecycle:lifecycle-extensions-ktx:$lifecycleKtxVersion",
],
recyclerview : "androidx.recyclerview:recyclerview:$androidXVersion",
fragment : [
@@ -60,11 +65,14 @@ ext {
],
junit : "junit:junit:$junitVersion",
kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion",
+ coroutines : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion",
kotlinReflect : "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
robolectric : "org.robolectric:robolectric:$robolectricVersion",
rxjava : "io.reactivex.rxjava3:rxjava:3.1.1",
rxandroid : "io.reactivex.rxjava3:rxandroid:3.0.0",
rxrelays : "com.jakewharton.rxrelay3:rxrelay:3.0.1",
- truth : "com.google.truth:truth:$truthVersion"
+ truth : "com.google.truth:truth:$truthVersion",
+ coroutinesTest : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesVersion"
+
]
}
diff --git a/formula-coroutines/.gitignore b/formula-coroutines/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/formula-coroutines/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/formula-coroutines/build.gradle b/formula-coroutines/build.gradle
new file mode 100644
index 000000000..2143f8374
--- /dev/null
+++ b/formula-coroutines/build.gradle
@@ -0,0 +1,21 @@
+plugins {
+ id 'java-library'
+ id 'kotlin'
+}
+
+java {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+}
+
+dependencies {
+ implementation libraries.kotlin
+ implementation libraries.coroutines
+
+ api project(":formula")
+
+ testImplementation project(":formula-test")
+ testImplementation libraries.truth
+ testImplementation libraries.junit
+ testImplementation libraries.coroutinesTest
+}
\ No newline at end of file
diff --git a/formula-coroutines/src/main/java/com/instacart/formula/coroutines/FlowFormula.kt b/formula-coroutines/src/main/java/com/instacart/formula/coroutines/FlowFormula.kt
new file mode 100644
index 000000000..c58ea6c07
--- /dev/null
+++ b/formula-coroutines/src/main/java/com/instacart/formula/coroutines/FlowFormula.kt
@@ -0,0 +1,18 @@
+package com.instacart.formula.coroutines
+
+import com.instacart.formula.Stream
+import com.instacart.formula.StreamFormula
+import kotlinx.coroutines.flow.Flow
+
+abstract class FlowFormula : StreamFormula() {
+
+ abstract override fun initialValue(input: Input): Output
+
+ abstract fun flow(input: Input): Flow