Skip to content

Commit

Permalink
Fix onCreate generation - fix #84
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgiuliani committed Jun 5, 2023
1 parent 504dd67 commit dfcd5eb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ fun OutputStream.generateDefinition(def: KoinMetaData.Definition, label: () -> S
val ctor = generateConstructor(def.parameters)
val binds = generateBindings(def.bindings)
val qualifier = def.qualifier.generateQualifier()
val createAtStart = if (def.isType(SINGLE) && def.isCreatedAtStart == true) CREATED_AT_START else ""

val createAtStart = if (def.isType(SINGLE) && def.isCreatedAtStart == true) {
if (qualifier == "") CREATED_AT_START else ",$CREATED_AT_START"
} else ""
val space = if (def.isScoped()) NEW_LINE + "\t" else NEW_LINE
appendText("$space${def.keyword.keyword}($qualifier$createAtStart) { ${param}${label()}$ctor } $binds")
}
Expand All @@ -46,7 +47,7 @@ fun OutputStream.generateClassDeclarationDefinition(def: KoinMetaData.Definition
generateDefinition(def) { "${def.packageName}.${def.className}" }
}

const val CREATED_AT_START = ",createdAtStart=true"
const val CREATED_AT_START = "createdAtStart=true"

private fun List<KoinMetaData.ConstructorParameter>.generateParamFunction(): String {
return if (any { it is KoinMetaData.ConstructorParameter.ParameterInject }) "params -> " else ""
Expand Down
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext {

// Koin
koin_ksp_version = "1.2.2"
koin_version = '3.4.2'
koin_version = '3.4.1'

// Kotlin
kotlin_version = '1.8.21'
Expand Down
2 changes: 1 addition & 1 deletion sandbox/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official
kotlinVersion=1.8.21
koinVersion=3.4.1
koinAndroidVersion=3.4.1
koinKspVersion=1.2.1
koinKspVersion=1.2.2
kspVersion=1.8.21-1.0.11
androidGradleVersion=4.3.1
appcompatVersion=1.6.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.koin.core.annotation.Module
import org.koin.core.annotation.Single
import org.koin.example.`interface`.MyInterfaceExt

@Single
@Single(createdAtStart = true)
public class MyOtherComponent3(public val i : MyInterfaceExt)

@Module
Expand Down

0 comments on commit dfcd5eb

Please sign in to comment.