Closed EmmanueleVilla closed 4 years ago
I've managed to add the js target with these dependencies:
[...]
js()
[...]
sourceSets["jsMain"].dependencies {
implementation(Deps.Ktor.js) //"io.ktor:ktor-client-js:${Versions.ktor}"
implementation(Deps.Ktor.jsCore) //"io.ktor:ktor-client-core-js:${Versions.ktor}"
implementation(Deps.Ktor.jsJson) //"io.ktor:ktor-client-json-js:${Versions.ktor}"
implementation(Deps.Ktor.jsLogging) //"io.ktor:ktor-client-logging-js:${Versions.ktor}"
implementation(Deps.Ktor.jsSerialization) //"io.ktor:ktor-client-serialization-js:${Versions.ktor}"
implementation(Deps.Coroutines.js) //"org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Versions.coroutines}"
implementation(Deps.koinCoreJS) //"org.koin:koin-core-js:${Versions.koin}"
}
There's not a version of sqldelight for js, so I worked around it:,
//stubbing sql driver since it's not yet present in js
val sqlDriver = object : SqlDriver {
override fun close() {
}
override fun currentTransaction(): Transacter.Transaction? = null
override fun execute(
identifier: Int?,
sql: String,
parameters: Int,
binders: (SqlPreparedStatement.() -> Unit)?
) {}
override fun executeQuery(
identifier: Int?,
sql: String,
parameters: Int,
binders: (SqlPreparedStatement.() -> Unit)?
): SqlCursor = object : SqlCursor {
override fun close() {}
override fun getBytes(index: Int): ByteArray? = null
override fun getDouble(index: Int): Double? = null
override fun getLong(index: Int): Long? = null
override fun getString(index: Int): String? = null
override fun next(): Boolean = false
}
override fun newTransaction(): Transacter.Transaction = object : Transacter.Transaction() {
override val enclosingTransaction: Transacter.Transaction?
get() = null
override fun endTransaction(successful: Boolean) {
}
}
}
I've already modified the whole template because I want to use redux-kotlin as the architecture, but I could make a pull request where I add js + tests to this template with a react companion project if you are interested, let me know! Meanwhile I'll test everything in my project
Hi, Thanks for checking out KaMPKit. As you found, we want to keep it focused on Mobile development and intentionally don't include other targets. Heads up, SQLDelight does have an in memory js driver https://github.com/cashapp/sqldelight/pull/1486 . But it's not currently published so you need to build it: https://github.com/cashapp/sqldelight/issues/1667
I'd like to setup a sample app for my boss and I stumbled upon this awesome template! My aim is to develop also a react application using the same codebase. Is there a reason why there is no js target in the gradle file and the template is just for android & ios? Will I be able to add it or are some libraries that you use non-compatible with that platform?