Skip to content

Commit

Permalink
Merge pull request #24 from Trendyol/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
yigitozgumus authored Aug 29, 2024
2 parents f7df530 + 7cf02be commit cd12235
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 130 deletions.
145 changes: 73 additions & 72 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,90 +1,91 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.android.hilt)
alias(libs.plugins.jetbrains.kotlin.kapt)
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.android.hilt)
alias(libs.plugins.jetbrains.kotlin.kapt)
}

android {
namespace = "com.trendyol.transmission"
compileSdk = 34
namespace = "com.trendyol.transmission"
compileSdk = 34

defaultConfig {
applicationId = "com.trendyol.transmission"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
defaultConfig {
applicationId = "com.trendyol.transmission"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.7"
}
kapt {
correctErrorTypes = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
buildTypes {
release {
isMinifyEnabled = true
isDebuggable = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.7"
}
kapt {
correctErrorTypes = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
implementation(project(":transmission"))
testImplementation(project(":transmission-test"))
implementation(project(":transmission"))
testImplementation(project(":transmission-test"))

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)


implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.androidx.lifecycle.viewmodel)
implementation(libs.androidx.lifecycle.runtime.compose)

implementation(libs.hilt.android)
kapt(libs.hilt.android.compiler)
implementation(libs.hilt.android)
kapt(libs.hilt.android.compiler)

implementation(libs.androidx.material3)
testImplementation(libs.junit)
implementation(libs.androidx.material3)
testImplementation(libs.junit)

testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.junit)
testImplementation(kotlin("test"))
testImplementation(libs.turbine)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.junit)
testImplementation(kotlin("test"))
testImplementation(libs.turbine)

androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.trendyol.transmission.features.multioutput.multiOutputTransformerIden
import com.trendyol.transmission.transformer.Transformer
import com.trendyol.transmission.transformer.dataholder.dataHolder
import com.trendyol.transmission.transformer.handler.HandlerRegistry
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.handler.handlers
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.handler.onSignal
import com.trendyol.transmission.transformer.request.Contracts
import com.trendyol.transmission.transformer.request.dataHolder
Expand All @@ -19,7 +19,7 @@ val colorPickerIdentity = Contracts.identity("ColorPicker")

class ColorPickerTransformer @Inject constructor(
@DefaultDispatcher private val defaultDispatcher: CoroutineDispatcher
) : Transformer(defaultDispatcher, colorPickerIdentity) {
) : Transformer(colorPickerIdentity, defaultDispatcher) {

private val holder = dataHolder(ColorPickerUiState(), holderContract)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.trendyol.transmission.features.colorpicker.ColorPickerEffect
import com.trendyol.transmission.transformer.Transformer
import com.trendyol.transmission.transformer.dataholder.dataHolder
import com.trendyol.transmission.transformer.handler.HandlerRegistry
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.handler.handlers
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.handler.onSignal
import com.trendyol.transmission.transformer.request.Contracts
import com.trendyol.transmission.transformer.request.computation
Expand All @@ -15,6 +15,7 @@ import com.trendyol.transmission.transformer.request.computation.computations
import com.trendyol.transmission.transformer.request.computation.register
import com.trendyol.transmission.transformer.request.computationWithArgs
import com.trendyol.transmission.transformer.request.dataHolder
import com.trendyol.transmission.transformer.request.identity
import com.trendyol.transmission.ui.InputUiState
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.delay
Expand All @@ -23,7 +24,7 @@ import kotlin.time.Duration.Companion.seconds

class InputTransformer @Inject constructor(
@DefaultDispatcher private val defaultDispatcher: CoroutineDispatcher
) : Transformer(defaultDispatcher) {
) : Transformer(Contracts.identity("InputTransformer"), defaultDispatcher) {

private val holder = dataHolder(InputUiState(), holderContract)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.trendyol.transmission.features.output.OutputTransformer
import com.trendyol.transmission.transformer.Transformer
import com.trendyol.transmission.transformer.dataholder.dataHolder
import com.trendyol.transmission.transformer.handler.HandlerRegistry
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.handler.handlers
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.request.Contracts
import com.trendyol.transmission.transformer.request.identity
import com.trendyol.transmission.ui.MultiOutputUiState
Expand All @@ -19,7 +19,7 @@ val multiOutputTransformerIdentity = Contracts.identity("MultiOutput")

class MultiOutputTransformer @Inject constructor(
@DefaultDispatcher private val defaultDispatcher: CoroutineDispatcher
) : Transformer(defaultDispatcher, multiOutputTransformerIdentity) {
) : Transformer(multiOutputTransformerIdentity, defaultDispatcher) {

private val holder = dataHolder(MultiOutputUiState())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import com.trendyol.transmission.features.input.InputTransformer
import com.trendyol.transmission.transformer.Transformer
import com.trendyol.transmission.transformer.dataholder.dataHolder
import com.trendyol.transmission.transformer.handler.HandlerRegistry
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.handler.handlers
import com.trendyol.transmission.transformer.handler.onEffect
import com.trendyol.transmission.transformer.request.Contracts
import com.trendyol.transmission.transformer.request.computation
import com.trendyol.transmission.transformer.request.computation.ComputationRegistry
Expand All @@ -22,6 +22,7 @@ import com.trendyol.transmission.transformer.request.execution
import com.trendyol.transmission.transformer.request.execution.ExecutionRegistry
import com.trendyol.transmission.transformer.request.execution.executions
import com.trendyol.transmission.transformer.request.execution.register
import com.trendyol.transmission.transformer.request.identity
import com.trendyol.transmission.ui.ColorPickerUiState
import com.trendyol.transmission.ui.OutputUiState
import com.trendyol.transmission.ui.theme.Pink80
Expand All @@ -33,7 +34,7 @@ import kotlin.time.Duration.Companion.seconds

class OutputTransformer @Inject constructor(
@DefaultDispatcher private val defaultDispatcher: CoroutineDispatcher
) : Transformer(defaultDispatcher) {
) : Transformer(Contracts.identity("OutputTransformer"), defaultDispatcher) {

private val holder = dataHolder(OutputUiState())

Expand Down
2 changes: 1 addition & 1 deletion transmission-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ publishing {
create<MavenPublication>("release") {
groupId = "com.trendyol"
artifactId = "transmission-test"
version = "1.2.0"
version = "1.2.1"
afterEvaluate {
from(components["java"])
}
Expand Down
2 changes: 1 addition & 1 deletion transmission/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ publishing {
create<MavenPublication>("release") {
groupId = "com.trendyol"
artifactId = "transmission"
version = "1.2.0"
version = "1.2.1"
afterEvaluate {
from(components["java"])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package com.trendyol.transmission.router

import com.trendyol.transmission.Transmission
import com.trendyol.transmission.effect.EffectWrapper
import com.trendyol.transmission.router.builder.TransmissionRouterBuilderScope
import com.trendyol.transmission.router.loader.TransformerSetLoader
import com.trendyol.transmission.transformer.Transformer
import com.trendyol.transmission.router.builder.TransmissionRouterBuilderScope
import com.trendyol.transmission.transformer.request.Contract
import com.trendyol.transmission.transformer.request.RequestHandler
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineExceptionHandler
Expand All @@ -22,6 +23,7 @@ import kotlinx.coroutines.launch
* Throws [IllegalStateException] when supplied [Transformer] set is empty
*/
class TransmissionRouter internal constructor(
identity: Contract.Identity,
internal val transformerSetLoader: TransformerSetLoader? = null,
internal val autoInitialization: Boolean = true,
dispatcher: CoroutineDispatcher = Dispatchers.Default,
Expand All @@ -31,10 +33,10 @@ class TransmissionRouter internal constructor(
private val exceptionHandler = CoroutineExceptionHandler { _, _ -> }
private val routerScope = CoroutineScope(SupervisorJob() + dispatcher + exceptionHandler)

private val _transformerSet : MutableSet<Transformer> = mutableSetOf()
private val _transformerSet: MutableSet<Transformer> = mutableSetOf()
internal val transformerSet: Set<Transformer> = _transformerSet

internal val routerName: String = this::class.simpleName.orEmpty()
internal val routerName: String = identity.key

private val signalBroadcast = routerScope.createBroadcast<Transmission.Signal>()
private val dataBroadcast = routerScope.createBroadcast<Transmission.Data>()
Expand Down Expand Up @@ -65,7 +67,7 @@ class TransmissionRouter internal constructor(
*/
fun initialize(loader: TransformerSetLoader) {
check(!autoInitialization) {
"TransmissionRouter is configured to initialize automatically."
"TransmissionRouter is configured to initialize automatically."
}
initializeInternal(loader)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package com.trendyol.transmission.router.builder

import com.trendyol.transmission.router.TransmissionRouter
import com.trendyol.transmission.transformer.request.Contract
import com.trendyol.transmission.transformer.request.Contracts
import com.trendyol.transmission.transformer.request.identity

object TransmissionRouterBuilder {

fun build(scope: TransmissionRouterBuilderScope.() -> Unit): TransmissionRouter {
fun build(
identity: Contract.Identity = Contracts.identity("router"),
scope: TransmissionRouterBuilderScope.() -> Unit
): TransmissionRouter {
val builder = TransmissionRouterBuilderInternal(scope)
return TransmissionRouter(
identity = identity,
transformerSetLoader =
builder.transformerSetLoader.takeIf { builder.autoInitialization },
autoInitialization = builder.autoInitialization,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.trendyol.transmission.router.builder

import com.trendyol.transmission.router.TransmissionRouter
import com.trendyol.transmission.transformer.request.Contracts
import com.trendyol.transmission.transformer.request.identity

object TransmissionTestingRouterBuilder {

fun build(scope: TransmissionTestingRouterBuilderScope.() -> Unit): TransmissionRouter {
val builder = TransmissionRouterBuilderInternal(scope)
return TransmissionRouter(
identity = Contracts.identity("testingRouter"),
transformerSetLoader = builder.transformerSetLoader,
dispatcher = builder.dispatcher,
registryScope = builder.registryScope
Expand Down
Loading

0 comments on commit cd12235

Please sign in to comment.