-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c0d3fc
commit ff4ec28
Showing
65 changed files
with
1,647 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
|
||
plugins { | ||
kotlin("multiplatform") | ||
kotlin("plugin.serialization") | ||
id("com.android.library") | ||
id("com.vanniktech.maven.publish") | ||
id("org.jetbrains.dokka") | ||
id("org.jetbrains.kotlinx.kover") | ||
id("co.touchlab.faktory.kmmbridge") | ||
`maven-publish` | ||
kotlin("native.cocoapods") | ||
id("kotlinx-atomicfu") | ||
} | ||
|
||
kotlin { | ||
android() | ||
jvm() | ||
iosArm64() | ||
iosX64() | ||
linuxX64() | ||
iosSimulatorArm64() | ||
js { | ||
browser() | ||
nodejs() | ||
} | ||
cocoapods { | ||
summary = "Market/repository" | ||
homepage = "https://github.com/MobileNativeFoundation/Store" | ||
ios.deploymentTarget = "13" | ||
version = libs.versions.store.get() | ||
} | ||
|
||
sourceSets { | ||
val commonMain by getting { | ||
dependencies { | ||
implementation(libs.kotlin.stdlib) | ||
implementation(libs.kotlinx.coroutines.core) | ||
} | ||
} | ||
|
||
val androidMain by getting | ||
val commonTest by getting { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
implementation(libs.turbine) | ||
implementation(libs.kotlinx.coroutines.test) | ||
} | ||
} | ||
} | ||
|
||
jvmToolchain(11) | ||
} | ||
|
||
android { | ||
namespace = "org.mobilenativefoundation.market.repository" | ||
|
||
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml") | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
minSdk = 24 | ||
targetSdk = 33 | ||
} | ||
|
||
lint { | ||
disable += "ComposableModifierFactory" | ||
disable += "ModifierFactoryExtensionFunction" | ||
disable += "ModifierFactoryReturnType" | ||
disable += "ModifierFactoryUnreferencedReceiver" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
} | ||
|
||
tasks.withType<DokkaTask>().configureEach { | ||
dokkaSourceSets.configureEach { | ||
reportUndocumented.set(false) | ||
skipDeprecated.set(true) | ||
jdkVersion.set(11) | ||
} | ||
} | ||
|
||
mavenPublishing { | ||
publishToMavenCentral(SonatypeHost.S01) | ||
signAllPublications() | ||
} | ||
|
||
addGithubPackagesRepository() | ||
kmmbridge { | ||
githubReleaseArtifacts() | ||
githubReleaseVersions() | ||
versionPrefix.set(libs.versions.market.get()) | ||
spm() | ||
} | ||
|
||
koverMerged { | ||
enable() | ||
|
||
xmlReport { | ||
onCheck.set(true) | ||
reportFile.set(layout.projectDirectory.file("kover/coverage.xml")) | ||
} | ||
|
||
htmlReport { | ||
onCheck.set(true) | ||
reportDir.set(layout.projectDirectory.dir("kover/html")) | ||
} | ||
|
||
verify { | ||
onCheck.set(true) | ||
} | ||
} | ||
|
||
atomicfu { | ||
transformJvm = false | ||
transformJs = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
POM_NAME=org.mobilenativefoundation.store | ||
POM_ARTIFACT_ID=paging5 | ||
POM_PACKAGING=jar |
6 changes: 6 additions & 0 deletions
6
...monMain/kotlin/org/mobilenativefoundation/market/repository/ConflictResolutionStrategy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
enum class ConflictResolutionStrategy { | ||
DESTRUCTIVE, // Overwrite local changes that haven't synced with the network | ||
DEFER, // Before pulling, push local changes that haven't synced with the network | ||
} |
7 changes: 7 additions & 0 deletions
7
...pository/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/DataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
enum class DataSource { | ||
MEMORY_CACHE, | ||
SOURCE_OF_TRUTH, | ||
NETWORK | ||
} |
24 changes: 24 additions & 0 deletions
24
...t/repository/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/Delete.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
fun interface Delete<K : Any, D : Any, E : Any> { | ||
suspend fun delete(request: Request<K, D>): Response<E> | ||
|
||
data class Request<K : Any, D : Any>( | ||
val key: K, | ||
val strategy: Strategy | ||
) | ||
|
||
data class Strategy( | ||
val caches: Boolean, | ||
val network: Boolean | ||
) | ||
|
||
sealed interface Response<out E : Any> { | ||
data object Success : Response<Nothing> | ||
|
||
data class Error<E : Any>( | ||
val error: E | ||
) : Response<E> | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
...y/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/MutableRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
interface MutableRepository<K : Any, D : Any, E : Any> : Repository<K, D, E>, Write<K, D, E> |
34 changes: 34 additions & 0 deletions
34
...ket/repository/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/Read.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
|
||
fun interface Read<K : Any, D : Any, E : Any> { | ||
suspend fun read(request: Request<K>): Response<D, E> | ||
|
||
data class Request<K : Any>( | ||
val key: K, | ||
val strategy: Strategy | ||
) | ||
|
||
sealed interface Response<out D : Any, out E : Any> { | ||
data class Success<D : Any>(val data: D, val origin: DataSource) : Response<D, Nothing> | ||
data class Error<E : Any>(val error: E) : Response<Nothing, E> | ||
} | ||
|
||
data class Strategy( | ||
val order: List<DataSource>, | ||
val conflictResolutionStrategy: ConflictResolutionStrategy | ||
) { | ||
companion object { | ||
val CACHE_FIRST = Strategy( | ||
order = listOf( | ||
DataSource.MEMORY_CACHE, | ||
DataSource.SOURCE_OF_TRUTH, | ||
DataSource.NETWORK | ||
), | ||
conflictResolutionStrategy = ConflictResolutionStrategy.DEFER | ||
) | ||
} | ||
} | ||
} | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
...pository/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/Repository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
interface Repository<K : Any, D : Any, E : Any> : | ||
Stream<K, D, E>, | ||
Read<K, D, E>, | ||
Delete<K, D, E> |
20 changes: 20 additions & 0 deletions
20
...t/repository/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/Stream.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
fun interface Stream<K : Any, D : Any, E : Any> { | ||
fun stream(request: Request<K>): Flow<Response<D, E>> | ||
|
||
data class Request<K : Any>( | ||
val key: K, | ||
val strategy: Strategy | ||
) | ||
|
||
sealed interface Response<out D : Any, out E : Any> { | ||
data class Success<D : Any>(val data: D) : Response<D, Nothing> | ||
data class Error<E : Any>(val error: E) : Response<Nothing, E> | ||
data object Loading : Response<Nothing, Nothing> | ||
} | ||
|
||
sealed interface Strategy | ||
} |
27 changes: 27 additions & 0 deletions
27
...et/repository/src/commonMain/kotlin/org/mobilenativefoundation/market/repository/Write.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.mobilenativefoundation.market.repository | ||
|
||
fun interface Write<K : Any, D : Any, E : Any> { | ||
fun write(request: Request<K, D>): Response<D, E> | ||
|
||
data class Request<K : Any, D : Any>( | ||
val key: K, | ||
val data: D, | ||
val strategy: Strategy | ||
) | ||
|
||
data class Strategy( | ||
val caches: Boolean, | ||
val network: Boolean | ||
) | ||
|
||
sealed interface Response<D : Any, E : Any> { | ||
data class Success<D : Any>( | ||
val data: D | ||
) : Response<D, Nothing> | ||
|
||
data class Error<E : Any>( | ||
val error: E | ||
) : Response<Nothing, E> | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
experimental/market/src/commonMain/kotlin/org/mobilenativefoundation/market/Market.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.mobilenativefoundation.market | ||
|
||
interface Market { | ||
interface State | ||
interface Action | ||
interface Middleware | ||
|
||
fun interface Reducer<S : State, A : Action> { | ||
fun reduce(state: S, action: A): S | ||
} | ||
} |
Oops, something went wrong.